Activity › Forums › Adobe After Effects › Rotation expression
-
Rotation expression
Posted by Gavin Edwards on August 27, 2013 at 4:37 pmHi there, i’m hoping someone can help me with this, i’m thinking a simple expression should work it out.
I have an object parented to a null situated a about 80pix away from it. I want to be able to rotate the null and for the object spin around it but to always remain upright.
Any clues greatly appreciated.
Gavin Edwards replied 12 years, 8 months ago 3 Members · 4 Replies -
4 Replies
-
Mathew Fuller
August 27, 2013 at 5:25 pmThis generates perfect circular motion centered around the original position of the layer. I recommend that you map the radius and
cycle inputs to Expression Control sliders, and the phase input to an Expression Control angle.
Apply this expression to the position of the layer.radius = 75; // the radius of the circle
cycle = 1; // number of seconds to complete a circle; higher value = slower
if(cycle ==0){cycle = 0.001;} //avoids a “divide by zero” error
phase = 27; // initial angle in degrees from bottom
reverse = 1; // 1 for ccw, -1 for cw
x = Math.sin( reverse * degrees_to_radians(time * 360 / cycle + phase));
y = Math.cos(degrees_to_radians(time * 360 / cycle + phase));
add(mul(radius, [x, y]), position)My Work:
https://www.morecompletefx.com -
Mathew Fuller
August 27, 2013 at 5:26 pmApply this Expression to the Rotation channel of any layer you wish to control,
Set LookAt, below, to the name of the layer you wish the layer to look at.
If the controlled layer is not initially pointing straight up, enter an offset amount in degrees, below, to adjust the direction it is
looking.LookAt = “ball”
offset = 0
diffx = position[0] – this_comp.layer(LookAt).position[0];
diffy = position[1] – this_comp.layer(LookAt).position[1];
if (diffx == 0) {
diffx = 1 }
sign = 1 + (-1 * (diffx / Math.abs(diffx))) * 90;
radians_to_degrees(Math.atan(diffy/diffx)) + sign + offsetMy Work:
https://www.morecompletefx.com -
Walter Soyka
August 27, 2013 at 6:04 pmThis will need a semicolon at the end of the “offset = 0” line.
The super-simple way to offset rotation when one object is parented to another is to alt-click the child object’s rotation property, type a minus, then drag the pickwhip to the parent object’s rotation property.
You’ll end up with something like this:
-thisComp.layer("Parent").transform.rotationNot as robust as Matt’s solutions, but works well for keeping children level while their parent rotates.
Walter Soyka
Principal & Designer at Keen Live
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
RenderBreak Blog – What I’m thinking when my workstation’s thinking
Creative Cow Forum Host: Live & Stage Events -
Gavin Edwards
August 27, 2013 at 7:53 pmThankyou Walter, your super simple solution works good.
Thanks also Mathew, i’ll check out those expressions too.
Reply to this Discussion! Login or Sign Up