Highlighted

## Calculate the traveled distance

Participant ,
Jul 09, 2018

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

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.

Views

207

Likes

Report

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

## Calculate the traveled distance

Participant ,
Jul 09, 2018

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

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.

Views

208

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
3 Replies
LEGEND ,
Jul 09, 2018

Copied

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

Likes

Report

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

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.

Likes

Report

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

Copied

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.

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Resources
Troubleshooting
Knowledge Base Articles
Getting Started