CompGeoJS Quadratic Bezier


I just released a preliminary version of the CompGeJS quadratic Bezier.  This version has all the y-at-x, x-at-y, x-at-t, length-at-t, and similar methods with full arc-length parameterization.  I have not, however, implemented getX() and getY() queries with arc-length parameterization selected.  These only work with natural parameterization.

Triangular bounds are already available from the geometric constraints of the quadratic curve.  In a future GeomUtils class, I will provide min-x, min-y, max-x, and max-y methods that work for any of the parametric curves.  These can be used to query an axis-aligned bounding box.

The basic quadratic Bezier demo is similar to the parametric line version. It exercises the same set of methods (t-at-x, get-x, get-y) as well as normalized arc length at the current natural parameter.  Normalized arc length, s, is in [0,1] and indicates the fraction of total arc length along the curve at a specific point.  In general t = s only when t = 0 or t = 1.

The t-at-x method is intended to work only for x-values in the range min-x to max-x.  It may work outside those ranges, but in some cases it does not.  In general, there could be two natural parameters, t, for the same x-coordinate.  The method only returns one.  I may modify that in  the future, depending on how people wish to use the quadratic Bezier class.

In the mean time, experiment with the current version and see what you think :)


Comments are closed.