Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Car wheel rotation on an angle

  • Car wheel rotation on an angle

    Posted by Ben Tillett on July 23, 2011 at 8:47 am

    Hi, hope someone can help.

    I’ve got a car set up so that the wheels rotate when the car is moved left to right. But I can’t work out how to extend the expression so that the car may move on a diagonal path with the wheels rotating correctly.

    Not sure if I explained that well, but imagine a car in 2D moving up and down the contours of a mountain. So not flat along the x-axis, but diagonally. Is there a way to modify the expression so the wheels rotate correctly?

    I think it has something to do with trig, and working out the hypotenuse dynamically based on the slope/angle of the car and the distance travelled in x and y.

    Thanks!

    Roger Maus replied 12 years ago 3 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    July 24, 2011 at 9:41 pm

    For an irregular path, you’ll probably have to calculate the length of terrain traversed frame by frame. I’d start with something like this:


    accum = 0;
    for (f = timeToFrames(inPoint); f <= timeToFrames(); f++){
    t = framesToTime(f);
    p0 = position.valueAtTime(t-thisComp.frameDuration);
    p1 = position.valueAtTime(t);
    accum += length(p1,p0);
    }
    accum*360/(Math.PI*width)

    Dan

  • Ben Tillett

    July 25, 2011 at 9:34 am

    Dan, thank you so much!!

    After a little tweaking for my particular situation, that worked a dream.

    Thank you sir,

    Ben

  • Roger Maus

    April 26, 2014 at 9:36 pm

    Sorry fo waking up this old lad…. can I make this work in 3D space too? how?

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