# AE ENHANCERS

Expressions/Scripts/Presets
 It is currently Wed May 22, 2013 4:32 pm

 All times are UTC - 8 hours [ DST ]

 Page 1 of 1 [ 3 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Calculating vector length and anglePosted: Sat Dec 12, 2009 12:58 pm

Joined: Mon Mar 17, 2008 3:25 pm
Posts: 8
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

 Attachments: line_measurement.aep.zip [6.41 KiB] Downloaded 107 times
Top

 Post subject: Re: Calculating vector length and anglePosted: Sat Dec 12, 2009 3:57 pm

Joined: Fri Dec 07, 2007 10:11 am
Posts: 128
Try this transformation at the end of your angle expression:

Code:
(ang+270)%360

where "ang" is your previous calculated value.

meaning your expression should be changed to this:
Code:
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+270)%360

Koby.

Top

 Post subject: Re: Calculating vector length and anglePosted: Sun Dec 13, 2009 3:05 am

Joined: Mon Mar 17, 2008 3:25 pm
Posts: 8
Thanks koby

Perfect !

>kenneth

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 3 posts ]

 All times are UTC - 8 hours [ DST ]

#### Who is online

Users browsing this forum: No registered users and 0 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ Announcements    Announcements Expressions    Expressions Library    Expressions Tutorials    Expression Discussion Scripts    General Scripts Library    Script Tutorials    Scripts Discussion    Script requests User Scripts    Paul Tuersley's Scripts    Impudent 1's Scripts Animation Presets    Animation presets Library
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group