Skip to main content
Inspiring
July 9, 2018
Answered

Calculate the traveled distance

  • July 9, 2018
  • 1 reply
  • 882 views

Hi !

I'm making a 3D sequence in which a spherical object in moving on a plane by following a curve (its way isn't straight). I want the object to rotate as it moved, and adapt its rotation speed to the distance it's travelling (or its speed).

So the rotation angle A, is given by A = (360*X)/(d*Pi) where X is the traveled distance (between 2 frames) and d the diameter of the sphere. So I need to find how to compute the X value.

Can you help me please !

Thanks

    This topic has been closed for replies.
    Correct answer Rick Gerard

    The diameter is all you need. Combine that with simple vector math and a little valueAtTime.

    Courtesy of Dan Ebberts:

    f = this_comp.frame_duration;

    dist = 0;

    j = 0;

    w = content("Ellipse 1").content("Ellipse Path 1").size[1]; // the diameter


    while (j < time){

      dist += length(position,position.value_at_time(time - f));

      j += f;

    }

    360*dist/(w*Math.PI)

    This is just one of my collection of more than 200 custom animation presets. I use them all the time to speed up my work.

    This one works with any ellipse shape layer where the ellipse is a perfect circle and the transform ellipse position is zeroed out so the shape layer anchor point is at the center of the circle.  To use it for a sphere rolling along a path you can either use the pick whip to grab the diameter of the sphere (multiply by 2 if you only have a radius value) or simply just type in the diameter for the "w" value.

    1 reply

    Dave_LaRonde
    Inspiring
    July 9, 2018

    How are you determining the diameter of the sphere?  What's your measurement?

    P.M.B
    Legend
    July 10, 2018

    I stink at math but at the risk of embarrassing myself,  here's what I think.

    Like Dave alluded to the unit of measure needs to be the same for the circumference of the circle and the length of the curve.

    So...pull up your rulers & determine the diameter of circle then do the math.

    For the curve, I believe you need to add together the pixels in x and the pixels in y.  So again using the comp window rulers.  Determine the length of the curve in x and the height of it in y.  Add those two numbers together and you have the distance in pixels (I think).

    Did I make sense?  Honestly I'll be surprised if I'm right.

    ~Gutterfish
    Rick GerardCommunity ExpertCorrect answer
    Community Expert
    July 10, 2018

    The diameter is all you need. Combine that with simple vector math and a little valueAtTime.

    Courtesy of Dan Ebberts:

    f = this_comp.frame_duration;

    dist = 0;

    j = 0;

    w = content("Ellipse 1").content("Ellipse Path 1").size[1]; // the diameter


    while (j < time){

      dist += length(position,position.value_at_time(time - f));

      j += f;

    }

    360*dist/(w*Math.PI)

    This is just one of my collection of more than 200 custom animation presets. I use them all the time to speed up my work.

    This one works with any ellipse shape layer where the ellipse is a perfect circle and the transform ellipse position is zeroed out so the shape layer anchor point is at the center of the circle.  To use it for a sphere rolling along a path you can either use the pick whip to grab the diameter of the sphere (multiply by 2 if you only have a radius value) or simply just type in the diameter for the "w" value.