Degrafa Closest Point on Quad. Bezier

Now that the Australian Open is over, I can return to devoting spare time to Degrafa.  The closest point to a quadratic Bezier demo is now online.  Screenshot is below.

Closest point on a quadratic Bezier
Closest point on a quadratic Bezier

The demo functions in the same manner as that for closest point on a cubic Bezier, illustrated here.  You should update from SVN to get the BezierUtils class.

View demo.

View source.


4 thoughts on “Degrafa Closest Point on Quad. Bezier

  1. Interesting.

    How would you go about finding the closest position when the curve has been constructed with arc length parametrization?

    1. Nick – the curves’ parameterization does not affect its shape; that is done by the geometric constraints. The algorithm is invariant wrt parameterization.


      – jim armstrong

  2. I’m not knowledgeable at all on the math behind this. Kudos to you for what you’ve put together.

    I do realize that arc length (re)parametrization does not affect the shape. I guess what I was trying to ask is more related to animating a sprite along a path.

    I haven’t looked into the code behind arc length parametrization, but I saw one of your other demos and noticed that the ‘t’ values differs in curve location and that it can be used in order to achieve a smoother animation with a constant velocity.

    I’m wondering (without looking at any of this in depth..yet) if it is possible for a sprite to “jump” off the path and when it falls back onto the path for it to continue animating (using arc length parametrization) from the position it lands.

  3. Nick – the short answer is yes. If the sprite leaves the curve, presumably you have some algorithm for computing the curve parameter of the point at which the sprite ‘lands’ back on the curve. Arc-length reparameterization at its simplest level is a matter of internal bookkeeping. If you ask for a particular point, it may be at t-0.6 and s=0.75, but geometrically it’s still the same point.

    Let’s take a trivial example. Suppose you animate a sprite along an arc-length parameterized path. At halfway along the length of the curve, the sprite jumps off the path. You want it to land back on the path three-quarters of the length along the curve. That’s two points, so you have some algorithm to compute a third point as an apex and fit a parabola between those three points. The sprite moves along that parabola and when it lands back on the path, you resume animating along the path from s=0.75 to s=1. Internally, the natural parameter values (our friendly t-parameter) will most likely be different, but you should not care. You are using parameter values of 0.5 and 0.75 to refer to length along the curve. That identifies specific points whose geometric location is invariant wrt parameterization.


    – jim armstrong

Comments are closed.