• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Calculate the traveled distance

Participant ,
Jul 09, 2018 Jul 09, 2018

Copy link to clipboard

Copied

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

Views

551

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jul 09, 2018 Jul 09, 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

...

Votes

Translate

Translate
LEGEND ,
Jul 09, 2018 Jul 09, 2018

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jul 09, 2018 Jul 09, 2018

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 09, 2018 Jul 09, 2018

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines