AE ENHANCERS

Expressions/Scripts/Presets
It is currently Fri Aug 22, 2014 10:30 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: adaptive rotation based on a point
PostPosted: Sat Mar 29, 2008 4:08 pm 
Offline

Joined: Sun Mar 23, 2008 6:50 am
Posts: 5
Hello!

I'm just working on a little project. I have an object that has animated position, and i wanted it to aim at the certain point. So here is a short amateurish expression i wrote:

Code:
x1 = content("Shape 1").transform.position[0];
y1 = content("Shape 1").transform.position[1];
x2 = -120;
y2 = 130;
value + [radiansToDegrees(Math.atan2(y1-y2, x1-x2))]


x1 and y1 is the object position (i was working with a shape, but you could pickwhip anything), while x2 and y2 are the target point coordinates. And i love that the after effects has built-in protection against division by 0 :P

All suggestions or fixes are welcome.


Top
 Profile  
 
 Post subject: Re: adaptive rotation based on a point
PostPosted: Thu Apr 03, 2008 4:34 am 
Offline

Joined: Thu Apr 03, 2008 3:22 am
Posts: 1
Location: Aarhus, Denmark
Just a small tweak that I use:

Code:
fromPoint=transform.position;
atPoint=thisComp.layer("Shape Layer 1").transform.position;
delta=sub(fromPoint,atPoint);
angle=Math.atan2(delta[1],delta[0]);
value+radiansToDegrees(angle)


It makes it easier just to select and pickwhip new points. The fromPoint is of course your source layer and the atPoint is where you want it to point.

I think I've seen an even easier way to do this, but I'll be blowed if I can remember it.

Cheers,
Ben

_________________
Curious Turtle Professional Video
Training | Editing |Support

www.curiousturtle.com


Top
 Profile  
 
 Post subject: Re: adaptive rotation based on a point
PostPosted: Fri May 23, 2008 7:35 am 
Offline

Joined: Fri May 23, 2008 6:51 am
Posts: 3
Ben I think you mean this:

Code:
lookAt(position,thisComp.layer("Target_Layer").transform.position)


Pop that into the 'Orientation' of a layer, and it will keep rotating to face the target layer. It stays aligned along the Z axis, so you may want to rotate the layer by 90 degrees on Y.

Yan Masterson
Spot Post Ltd.
London.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


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

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group