On Sun, 20 Nov 2005, Warren Francis wrote: > Basically, I'd like to specify a curved path of an object through space. > 3D space would be wonderful, but I could jimmy-rig something if I could > just get 2D... Are bezier curves really what I want after all?
No. You want a natural cubic spline: http://mathworld.wolfram.com/CubicSpline.html This is a fairly simple curve, which can be fitted through a series of points (called knots) in space of any dimensionality, without the need to specify extra control points (unlike a Bezier curve), and which has the nice property of minimising the curvature of the curve - it's the shape you'd get if you ran a springy wire through your knots. It usually looks pretty good too. Google will help you find python implementations. There are other kinds of splines - Catmull-Rom, B-spline (a generalisation of a Bezier curve), Hermite - but they mostly don't guarantee to pass through the knots, which might make them less useful to you. In the opposite direction on the mathematical rigour scale, there's what i call the blended quadratic spline, which i invented as a simpler and more malleable alternative to the cubic spline. It's a piecewise parametric spline, like the cubic, but rather than calculating a series of pieces which blend together naturally, using cubics and linear algebra, it uses simple quadratic curves fitted to overlapping triples of adjacent knots, then interpolates ('blends') between them to draw the curve. It looks very like a cubic spline, but the code is simpler, and the pieces are local - each piece depends only on nearby knots, rather than on all the knots, as in a cubic spline - which is a useful property for some jobs. Also, it's straightforward to add the ability to constrain the angle at which the curve passes through a subset of the knots (you can do it for some knots, while leaving others 'natural') by promoting the pieces to cubics at the constrained knots and constraining the appropriate derivatives. Let me know if you want more details on this. To be honest, i'd suggest using a proper cubic spline, unless you have specific problems with it. tom -- ... a tale for which the world is not yet prepared -- http://mail.python.org/mailman/listinfo/python-list