# How would I move an object using its velocity on a closed curve?

I want that an object follows a path, in Peggle game there are some pegs that have movement in a closed path. How can i get the same result? I guess that I can use parametric curve but I need use the velocity and not the position (x, y).

I use NAPE and I have this in my gameloop:

//circunference
angle = angle + 1*(Math.PI / 180);
movableBall.position.x = radius * Math.cos(angle)+ h;
movableBall.position.y = radius * Math.sin(angle)+ k;


It works but I can not control the velocity, each movableBall must have its own velocity. Besides, from docs of NAPE:

"Setting the position of a body is equivalent to simply teleporting the body; for instance moving a kinematic body by position is not the way to go about things.."

I want to use:

movableBall.velocity.x =??
movableBall.velocity.y = ??


The final idea is to follow others paths like the Lemniscate of Bernoulli.

• Typically for this site, you don't come here to ask for an answer. You come here to ask how to get an answer. If you want help with the latter we can oblige. But you'll need to tell us what you've tried already and what about it didn't work. Please edit your question with your response. – MichaelHouse Jun 11 '12 at 5:44

A parametric curve sounds OK. At specific t calculate the x and y coordinate for the object. Then update the object's position. The velocity will control the interval you update this. I think this should make your object follow the parametric curve.
• The object will follow the parametric curve but it will not have constant velocity, unless ||dM/dt|| is constant for every point M on the curve. – sam hocevar Jun 11 '12 at 8:55