Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Rotation worked out from y position of TWO nulls

  • Rotation worked out from y position of TWO nulls

    Posted by James Armstrong on July 9, 2009 at 10:07 am

    Hi,

    I have 2 characters carrying a box rendered out from c4D (profile view from the left). The box isn’t rendered out yet. As the characters hands move up and down as they walk I want to create an expression that takes the y position of a null at each pair of hands and rotates the box accordingly on the Z axis to make sure that the box corners are always in contact with each character’s hands. Make sense?

    I’m sure this won’t be too difficult for some of you geniuses out there!

    Thanks!

    Dan Ebberts replied 17 years, 2 months ago 2 Members · 1 Reply
  • 1 Reply
  • Dan Ebberts

    July 9, 2009 at 1:15 pm

    The rotation expression will look like this:

    p1 = thisComp.layer(“Null 1”).transform.position;
    p2 = thisComp.layer(“Null 2”).transform.position;
    d = p2 – p1;
    radiansToDegrees(Math.atan2(d[1],d[0]))

    If you want to keep the box centered between the two nulls you can use a position expression like this (possibly with an offset added if the box’s handles don’t line up with the anchor point):

    p1 = thisComp.layer(“Null 1”).transform.position;
    p2 = thisComp.layer(“Null 2”).transform.position;
    (p1 + p2)/2

    Dan

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