If you're trying to plot curved paths in real-time...

This forward differencing algorithm is the fastest I've found to date:
http://www.niksula.cs.hut.fi/~hkankaan/Homepages/bezierfast.html. Though it
is only suitable for purposes where the curve does not have to touch all the
control points.

And this recipe, mentioned by Ciro, makes a decent foundation for a Bezier
editor: http://www.pygame.org/wiki/BezierCurve. For my purposes I modified
it to use the forward differencing function, and print the control points on
demand.

To use real-time curves in this manner I had to solve the same problem you
mention, Mark, that the distance between points varies and results in
unwanted sprite speed variations. I ended up tracking sub-pixel sprite
position as a float, and advancing to the next curve point when the distance
traversed meets or exceeds the distance between the current and next point.

Here's a recipe for calculating point-to-point distance:
http://www.pygame.org/wiki/CalculateDist.

For straight lines I've successfully used vector math to move a sprite small
distances each frame at an arbitrary angle. This is very efficient for
motion along a vector, but floating point errors cause this method to be
imprecise. If you're moving to a specific point your sprite will most often
miss the point and end up orbiting it, which requires the addition of a
terminal test case based, for example, on a distance calculation. Still,
this is very efficient. It also requires some additional vector math to
compute angles and points on a circumference. If there is an interest I'm
willing to post a recipe for these.

Gumm

On Mon, Aug 16, 2010 at 11:01 PM, Mark Reed <markree...@gmail.com> wrote:

>
> Any path editors out there?
>
> Mark
>

Reply via email to