Archived

This topic is now archived and is closed to further replies.

DuckWizard

Catmull-Rom splines

Recommended Posts

DuckWizard    122
Hello, I''m thinking of using Catmull-Rom splines for animation paths. I want to have a set of points and their corresponding time values and be able to interpolate smoothly between them. Catmull-Rom splines seem very simple and almost perfect. The only gotcha is that with Catmull-Rom splines (from my understanding) the points must be equally spaced in time. My question is - is there any way they can be extended such that if I have the time value at each control point, I don''t have to make sure that the points are equally spaced? I want to have a set of arbitrary points and at what time the path should reach each one, instead of having p1 at t = 0, p2 at t = 1, p3 at t = 2, etc. Any ideas? Thanks, -Jeremy

Share this post


Link to post
Share on other sites
grhodes_at_work    1385
As szinkopa said, the points actually can be anywhere. But here is some stuff to consider that may clarify your understanding of splines:

The spline is typically written as a parametric function of the a knot parameter, where IF you decide that the parameter is time then the time from one knot to the next is the same for each knot. Because of this, if one segment of the spline is longer than the other, if you treat the parameter as time then the average velocity over the longer segment will be greater than the average velocity over the shorter segment, just so the object following each segment can arrive at the next knot at the same time. But, you do not HAVE to choose the parameter to be equal to time. You can do, among other things, an arc length parameterization in which the parameter is equal to the local length of the spline from the starting point. This enables you to have an object follow the spline with a constant velocity. Dave Eberly outlines this in detail over at:

Moving at Constant Speed (parameterize by arc length)

Graham Rhodes
Principal Scientist
Applied Research Associates, Inc.

Share this post


Link to post
Share on other sites
billybob    134
hmm, i had this problem myself for a while and i kept trying to find a way to find the arc length, but couldn''t. then however, i realized that you can just find the derivative at the current point, and use that to control the speed. if you divide the parameter increase by the length of the derivative vector, you get smooth movement. at least, i hope so. the best part it seems is that its pretty damn fast, no integration involved, so the points can move around without having to recalculate a definite integral every time they move, much less detect when they move and do it behind the scenes.

the only problem i could find is it requires that you move the parameter by a velocity, not a distance, which is not a problem for me but might be for you.

Share this post


Link to post
Share on other sites