In this post we are interested in being able to control the speed while moving along a parameterized spline curve. Moving on a curve with constant or accelerated motion is useful in several situations like when you want to move a camera along the path and you want to have control on the speed; or in a racing game where your tracks are parameterized curves and you need to be able to move along at different but controlled speeds.
The intention of this post is then to provide an approximation of constant velocity on a curve without the need of numerical methods. Furthermore, the method exposed here will have the following features:
- can be used on any parameterized spline curve (for example cubic bezier curves).
- can be used directly for accelerated motion, just by changing as desired the velocity parameter.
- O(n) space complexity, being $n$ a number of samples in the curve.
- O(n) run time complexity in the worst case scenenario at each iteration (query of next point in the curve given the current point).
- the approximation can be improved by tweaking a single parameter that improves the representation (sampling) of the curve.