The quadratic Bezier curve consists of two coordinate functions - x (t) and y (t), where.
These functions can have a maximum or minimum (points where x '(t) = 0 and y' (t) = 0), and these points are the boundary points aabb.
So the algorithm:
- Imagine that x0, y0, x1, y1, x2, y2 are known and calculate the values ββt (x0, x1, x2) and t (y0, y1, y2) when x '(t) = 0 and y' t) = 0 respectively.
- Calculate both values ββand check if they are = = 0 and <= 1. If they evaluate quadratic bezier points.
- Take the first and last points.
- Now you have 4 points (or maybe less), use them to calculate AABB.
By the way:
t (x0, x1, x2) = (x0 - x1) / (x2 - 2 * x1 + x0)
t (y0, y1, y2) = (y0 - y1) / (y2 - 2 * y1 + y0)
Here you can find the full code: https://github.com/keyten/Graphics2D/blob/Delta/Core/Curve.Math.js#L295
source share