Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Rotational velocity scripting woes

  • Rotational velocity scripting woes

    Posted by Ben Jaffe on March 5, 2008 at 8:05 pm

    Hi! I’m trying to get the rotational velocity of an object that is auto-orienting to a path. The object is a top-down view of a bicycle, and I’m trying to link the front wheel rotation to the bike’s rotation. (Once I get the rotation worked out, I’ll work the speed of the bike into the equation too.) I can’t get the bold section to work. I don’t know if I’m putting it in the wrong place, or if I need different syntax for this situation. The original code that I’m modifying gets the rotation of an object that is auto-oriented. Any help anyone can give would be very VERY appreciated.

    Mainly, I’m having the issue with getting the value of the object’s rotation a frame before, so I can determine how much the front wheel of the bike should be turned. Thanks so much, and here’s my code.

    L = comp(“Final Animation”).layer(“cyclist1”);
    u = L.toWorldVec([1,0]);
    uOld = L.toWorldVec([1,0]).valueAtTime(time-1); // <==here's where I'm getting my error r1 = radiansToDegrees(Math.atan2(u[1],u[0])); r2 = radiansToDegrees(Math.atan2(uOld[1],uOld[0])); r1 - r2

    Ben Jaffe replied 18 years, 2 months ago 3 Members · 3 Replies
  • 3 Replies
  • Filip Vandueren

    March 5, 2008 at 9:27 pm

    Hi Ben,

    valueAtTime only works when applied to a property, you can’t append it to a mathod or function like smooth, ease, or any of the layer Transforms.

    Lucky enough, most functions have a time-factor as one of their parameters.

    In your case this should work:
    uOld = L.toWorldVec([1,0],(time-1));

  • Dan Ebberts

    March 5, 2008 at 9:41 pm

    Yup, and if you want the value from one frame ago you’ll want something like this:

    uOld = L.toWorldVec([1,0],time – thisComp.frameDuration);

    I’m curious to see how you’re going to use the result of this expression. Please let us know how it turns out.

    Dan

  • Ben Jaffe

    March 5, 2008 at 10:21 pm

    That worked perfectly! Thank you so much!

    By the way, to get the speed, I’m using
    comp(“Final Animation”).layer(“cyclist1”).transform.position.speed

    and it works! I’ll post the final formula I use for the bike wheel when I finish it.

    Thanks again for the help!

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