Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Getting rotation value between two position values

  • Getting rotation value between two position values

    Posted by Mikkell Khan on June 4, 2010 at 11:06 pm

    I need an expression to get the rotation from two position values or to extrapolate the rotation from two position values. Eg. Ramp effect which has two points does not have a value for the rotation between these two points. There is a problem because I have an object that requires the need of such a value.

    The ramp is being used as an artificial sky and the object in question are clouds in the sky. I need to parent the cloud onto the sky but the footage has no points to track and the cinematography has a lot of rotation. The ramp is already animated to match that rotation.

    Gerben Greuliker replied 4 years, 4 months ago 4 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    June 4, 2010 at 11:39 pm

    Assuming that you’re talking about 2D, this may be close to what you’re looking for:

    L1 = thisComp.layer(“Layer 1”);
    L2 = thisComp.layer(“Layer 2”);
    p1 = L1.toWorld(L1.anchorPoint);
    p2 = L2.toWorld(L2.anchorPoint);
    delta = p2 – p1;
    radiansToDegrees(Math.atan2(delta[1],delta[0]));

    Dan

  • Fud Hodgkinson

    September 29, 2019 at 6:30 am

    Hi there! WOuld you have any idea of how to get this expression to work for 3D space between two 3d nulls?

    I did a screencap of my problem here:
    https://youtu.be/jRHFRCFB2v8

    The position works perfectly however I can’t get the rotational value between two 3d nulls.

    Thanks!

    Some contents or functionalities here are not available due to your cookie preferences!

    This happens because the functionality/content marked as “Google Youtube” uses cookies that you choosed to keep disabled. In order to view this content or use this functionality, please enable cookies: click here to open your cookie preferences.

  • Gerben Greuliker

    December 24, 2021 at 1:52 pm

    Hi Dan,

     

    I’m working on an animation where two wheels of a car move separately on a bumpy road and the chassis has to rotate according the value of these two wheels. Looking at this expression I think this will do the trick. But when I apply the expression I get a syntax error on the ‘delta’. Seeing this expression is from the year 2010 I assume the error has to do with it being written in the ‘old’ action scripting format. Is there a simple update to fix this?

    thnx in advance!

     

    Gerben Greuliker

  • Dan Ebberts

    December 24, 2021 at 5:00 pm

    A lot of the old expressions got mangled when they updated this site. The straight quotes got converted to curly quotes and the minus signs got converted to some other character. This should work better:

    L1 = thisComp.layer("Layer 1");
    L2 = thisComp.layer("Layer 2");
    p1 = L1.toWorld(L1.anchorPoint);
    p2 = L2.toWorld(L2.anchorPoint);
    delta = p2 - p1;
    radiansToDegrees(Math.atan2(delta[1],delta[0]));
  • Gerben Greuliker

    January 3, 2022 at 12:51 pm

    Thnx Dan!

    I just happen to find this code on another site.
    It uses position as the source but works the same.

    p1 = thisComp.layer("Start").transform.position;
    p2 = thisComp.layer("End").transform.position;
    v = p2 - p1;
    radiansToDegrees(Math.atan2(v[1], v[0]));

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