Movement at constant speed on a curve
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?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement