Hi I need some help to finish my line measurement tool.
Edit: Sorry !  this should have been posted under Expression Discussion  please move
Sometimes I need to calculate the distance and angle between two points on the screen, so I'm working on an animation preset.
I use the beam effect to select the two points and an expression to calculate the length and angle of the line.
Calculating the length work fine, but the angle are giving me problems.
I use the expression found here : http://www.jjgifford.com/expressions/ge ... tions.html
At the moment it returns values between 180 and 180 and have 0 at "9 o'clock"
I want it to return values between 0 and 360 and have 0 at "12 o'clock" 90.dg at "3 o'clock" 180dg. at "6 o'clock" and 270dg. at "9 o'clock"
Can anyone help me ?
AfterEffects CS4 project attached
red value = length
yellow value = angle
>kenneth
Calculating vector length and angle
Moderator: byronnash

 Posts: 7
 Joined: March 17th, 2008, 3:25 pm
 Attachments

 line_measurement.aep.zip
 (6.41 KiB) Downloaded 590 times
Try this transformation at the end of your angle expression:
where "ang" is your previous calculated value.
meaning your expression should be changed to this:
Koby.
Code: Select all
(ang+270)%360
meaning your expression should be changed to this:
Code: Select all
this_point=effect("line")("Starting Point");
that_point=effect("line")("Ending Point");
delta=sub(this_point, that_point);
angle=Math.atan2(delta[1], delta[0]);
ang = radians_to_degrees(angle);
(ang+270)%360