Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Expression to orbit value of keyframes with the layer’s anchor point

  • Expression to orbit value of keyframes with the layer’s anchor point

    Posted by Stephan Zammit on May 5, 2022 at 2:09 pm

    Hi,

    I am trying to create an expression where the whole position animation of an object can be rotated with regards to the layers anchor point.

    So to put this into a simple scenario we have the following.

    We have 2 position keyframes;

    – Keyframe 1 with a value of 0,100.

    – Keyframe 2 has a value of 0,0.

    – The Anchor Point is 0,0.

    I would like to link this somehow to an angle control, so that if I rotate the angle control to 90 Degrees, the first keyframe will be of value 100,0.

    Of course the scenario can be more complex with more keyframes in between and so on.

    Basically acting as if it was parented to its ‘Anchor Point, position’, and its ‘anchor point’ is being rotated carrying the whole rotation with it.

    Can anyone pitch in? Till now I had been trying to parent the separate x, y values with a slider control. Basically valueX*sliderValueX, but this is very limiting for our project.

    Would greatly appreciate any feedback 🙂

    Thanks!

    Stephan Zammit replied 4 years ago 2 Members · 2 Replies
  • 2 Replies
  • Filip Vandueren

    May 6, 2022 at 12:13 pm

    The easy solution would be to parent to a Null and rotate the Null.

    Also, the position of the anchorPoint isn’t really relevant in this problem, I think.
    The rotation would have to happen relative to a point of the composition (for example [0,0], or the position of the layer’s first psoiton keyframe etc.)

    That being said, here’s an expression that would work:

    rotationPoint = [0,0];
    rotationAngle = degreesToRadians(90);
    vector = value - rotationPoint;
    angle = Math.atan2(vector[1],vector[0]) + rotationAngle;
    rotationPoint + [Math.cos(angle), Math.sin(angle)]*length(vector);
  • Stephan Zammit

    May 9, 2022 at 12:36 pm

    Hi Filip,

    Yes that’s exactly the intention, to bypass the Null layer, to make the project a bit more simple, when working with a large number of layers.

    Just tested this with my project and it works perfectly! Thank you so much for your help! Greatly Appreciated! 🙂

    How would this be altered if I were to plug this into the Rotation Value as well, so that it acts as if it was parented to the null.

    Many thanks!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy