← Back to context

Comment by exDM69

1 day ago

> What's a "monotonic Bezier curve"?

Good question!

It's a Bezier curve that has a non-zero derivative for t=0..1 (exclusive).

Just your high school calculus definition of monotonic.

To get from a general quadratic Bezier to monotonic sections, you solve the derivative for zeros in x and y direction (a linear equation). If the zeros are between 0 and 1 (exclusive), split the Bezier curve using de Casteljau's at t=t_0x and t=t_0y. For each quadratic Bezier you get one to three monotonic sections.

> every Bezier curve is contained within its control points' convex hull.

This is true, but only monotonic Bezier curves are contained between the AABB formed by the two end points (so control points in the middle don't need to be considered outside the AABB).

For a quadratic Bezier this means that it is monotonic iff the middle control point is inside the AABB of the two end points.

The monotonicity is a requirement for all the GPU warp level AABB magic to happen (which is a nice 10x to 20x perf increase in my benchmarks). At worst you'd have to deal with 3x the number of curves after splitting (still a win), but because most curves in fonts are monotonic the splitting doesn't increase the the number of curves a lot in practice.

Monotonicity also implies that the quadratic equations have only one unique solution for any horizontal or vertical line. No need to classify the roots as in Lengyel's method.