A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Arc based on Start/End points and Radius- Mostly done

Hybrid View

  1. #1
    Bacon-wrapped closures Nialsh's Avatar
    Join Date
    Dec 2003
    Location
    Houston!
    Posts
    338
    If I'm not mistaken, you're on the wrong track. Constructing an arc from two points and a radius is a very different problem from the three-point construction.

    Given two points and a radius, there are 4 different arcs you can make (that lie on 2 circles). Here's some code that finds the centers of the 2 circles that the arcs can lie on:

    Code:
    //points (x1,y1) and (x2,y2)
    //radius r
    var mx = (x1+x2)/2;
    var my = (y1+y2)/2;
    
    var leg1x = mx-x1;
    var leg1y = my-y1;
    var leg1 = Math.sqrt(leg1x*leg1x + leg1y*leg1y);
    
    if(leg1 > Math.abs(r))
    	return; //no solution
    
    var leg2 = Math.sqrt(r*r - leg1*leg1);
    var leg2x = leg1y*leg2/leg1;
    var leg2y = -leg1x*leg2/leg1;
    
    var c1x = mx+leg2x;
    var c1y = my+leg2y;
    
    var c2x = mx-leg2x;
    var c2y = my-leg2y;
    You can probably work from that to construct the arc you want.

  2. #2
    Junior Member
    Join Date
    Jun 2010
    Posts
    1

    Thanks!

    Hi Nialsh. Thanks a lot for this! I have been trying to get this working for days..

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center