Sign in to follow this  
_Flecko

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 this post


Link to post
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this