Movement at constant speed on a curve

Recommended Posts

In my side-scrolling game, terrain is modeled by a set of 3rd degree polynomials f(x)=ax^3+bx^2+cx+d on [0,128] which each define the height of the land on an area of that size. To model a particle moving along the ground at a constant rate, I tried to parameterize the curve with respect to arc length, but I can't quite get it working. Here's what I did: -Rewrite the curve as r(t)=<t,f(t)> -Take |r'(t)|=Sqrt(9a^2t^4+12abt^3+(6ac+4b^2)x^2+4bcx+c^2+1) -Use s(t)=t/|r'(t)| as a parameter If I understand correctly, the point given by r(s(t)) is at arc length t on the curve. However, I must be doing something wrong, because my particle moves at variable speed even as I increase t at a constant rate, even skipping around sometimes. Where's my mistake?

Share on other sites
I'll just point you to a doc by Dave Eberly:

Moving at Constant Speed

Share on other sites
Works beautifully, thanks much. I'd never heard of Newton's method before, that's really clever. The directory it's in looks great, too, I wish I'd known about this a while ago.

Create an account

Register a new account

• Forum Statistics

• Total Topics
628394
• Total Posts
2982427

• 10
• 9
• 19
• 24
• 9