## New Quad. Bezier Methods

When using Bezier curves to approximate trajectories in path animation, it can be useful to query extreme points. This query can be used, for example, to test if an auto-generated path between two points exceeds a bound. For quadratic Beziers, there are three critical points in [0.1]; the endpoints and a possible third point where the derivative is zero. Four methods, tAtMinX(), tAtMaxX(), tAtMinY(), and tAtMaxY() were added to the IParametric Interface, although the only concrete implementation is currently for Bezier2.

The following screen shot illustrates an example of a quad. Bezier trajectory auto-generated between two endpoints. The red Knots indicate maximum y-value (y-down is positive in Flash) and the green Knots indicate minimum y-value.

In this case, tAtMinY() indicates the parameter value at the top of the trajectory from the point of view of the user. The Bezier2 class also has a working implementation of toString(), although some thought is required as to how it should be implemented for arbitrary parametric curves. The usual work in progress 🙂

As always, Singularity can be downloaded here. Experiment and have fun!

Oh that’s nice – if I’m not mistaken this can also be useful to calculate the bounding box of a shape that uses quad beziers. Thinking about this – I think you could easily add another method now: Bezier2.getBounds().

That’s an interesting idea, Mario.

thanks,

– jim

Hi. I’ve only recently discovered your site. Very interesting. I really like all the Bezier stuff, but haven’t given it a go yet. At first I thought you were doing bounding boxes too. I’m guessing it isn’t trivial to figure the xMin or xMax since you can’t count on them being the segment end points. Right?

PS: I’m really looking forward to the y at x!

Rothrock – the y at x methods for quad and cubic Beziers are coming, although there will be one interim development in preparation for that.

regards,

– jim