January 7, 2009

The initial set of new methods includes automatic 3-point interpolation with chord-length parameterization.  The 3-point interpolation normally used in the Flash community is really a midpoint formula that is a special case of the general formula.  The general formula is discussed in this TechNote and illustrated in this online demo.  The functionality prevously available in the Singularity Bezier2 class is now available to Degrafa users.

The computation of t-parameter at extreme points has also been ported.  So, you can query the parameter value in [0,1] where the x- or y-coordinate is a maximum or minimum.  I’ve used this before in applications where a quad. Bezier represents a trajectory for animating a sprite.  The start and end points are variable.  Finding the extreme y-coordinate (quickly) is necessary to ensure the trajectory does not cause the sprite to pass into invalid areas in the display space.

The y-at-x method is also available, but not yet tested.  That one is pretty much look but don’t touch at this point 🙂  I hope to have a test program written over the weekend.

The screenshot below illustrates sample output from the advanced quad. Bezier demo.  Prior demos used the draggable points to set control points for a quad. Bezier.  This demo uses them to set interpolation points.  Notice how the Bezier passes through all three points.  The red lines illustrate the results from the bounding methods, which is also a way to quickly compute a bounding rectangle for the Bezier curve, including the t-parameters at which the bounds occur.

I will continue to add new methods to this class as needed and hope to follow on with an advanced cubic Bezier class in the near future.  The Singularity BezierUtils class will eventually be ported as well (providing the ability to query the closest point on a quad. or cubic Bezier to an arbitrary point).

View Demo

View Source

Categories: Degrafa, Flex
1. January 7, 2009 at 8:13 pm

The bounding information is cool – haven’t seen that before in any of my classes.

2. January 8, 2009 at 10:41 am

JT – I think you’ve had calculus. Compute dy/dt and dx/dt (which is pretty simple given the quadratic polynomial coefficients). Set these equal to zero and compare the stationary points with coordinates of each endpoint.

regards,

– jim