Movement at constant speed on a curve

Started by
1 comment, last by _Flecko 18 years, 9 months ago
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?
--------------Trans2D - 2D library for C# / Managed DirectX
Advertisement
I'll just point you to a doc by Dave Eberly:

Moving at Constant Speed
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net
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.
--------------Trans2D - 2D library for C# / Managed DirectX

This topic is closed to new replies.

Advertisement