Oops.  Just noticed how atrocious the writing was.

On 3/18/2010 11:25 AM, Anthony Pace wrote:
Hi Pual,

I just noticed that I had already written something, but it didn't get sent to the list before the question got answered.

Oh well...anyways:

To find the angle, you have to find the slope of the tangent at that point of the curve; however, this is really easy because with bezier curves you already know the tangents for the end points.

the control points for the cage of a bezier are:
A(the beginning point that you will be curving from)
B(the middle)
C(the end point you curved to)

the slope of the line AtoB is the slope of the tangent for point A
the slope of the line BtoC is the slope of the tangent for point C

remember that the slope, m = deltaY/DeltaX, rise over run, (y1-y0)/(x1-x0)

Now that you have the slope for each line segment, and since m = tan (theta), then arc tan (m) = theta; therefore, pop in the slope, using Math.atan(m) to get the radian, or Math.atan(m) * 180 /Math.PI to get the degree.

You could also use atan2 reducing points by offset, but either way you need to use the ctrl points.

Now that you have the degree, if your arrow head are dynamically generated you know how what to translate the points by; however, if they are shapes than with the registration point located at the arrow head tip, then rotating should be a piece of cake from that point.

Hope that helps,
Anthony

On 3/16/2010 12:02 PM, [email protected] wrote:
I was recently asked if I could add some arrowheads to some actionscript
generated curves. I initially thought "Triangle pointing to end point", and that would be a great solution. I can place a MC at the end of the curve, but how can
I get the right angle to point it to?
  Paul
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to