|
|
Donner 0.5.0
Embeddable browser-grade SVG2 engine
|
Free functions for evaluating, splitting, approximating, and computing bounding boxes of quadratic and cubic Bezier curves. More...
Functions | |
| Vector2d | donner::EvalQuadratic (const Vector2d &p0, const Vector2d &p1, const Vector2d &p2, double t) |
Evaluate a quadratic Bezier curve at parameter t using the standard basis expansion. | |
| Vector2d | donner::EvalCubic (const Vector2d &p0, const Vector2d &p1, const Vector2d &p2, const Vector2d &p3, double t) |
Evaluate a cubic Bezier curve at parameter t using the standard basis expansion. | |
| std::pair< std::array< Vector2d, 3 >, std::array< Vector2d, 3 > > | donner::SplitQuadratic (const Vector2d &p0, const Vector2d &p1, const Vector2d &p2, double t) |
Split a quadratic Bezier curve at parameter t using De Casteljau subdivision. | |
| std::pair< std::array< Vector2d, 4 >, std::array< Vector2d, 4 > > | donner::SplitCubic (const Vector2d &p0, const Vector2d &p1, const Vector2d &p2, const Vector2d &p3, double t) |
Split a cubic Bezier curve at parameter t using De Casteljau subdivision. | |
| void | donner::ApproximateCubicWithQuadratics (const Vector2d &p0, const Vector2d &p1, const Vector2d &p2, const Vector2d &p3, double tolerance, std::vector< Vector2d > &out) |
| Approximate a cubic Bezier curve as a sequence of quadratic Bezier curves within a given tolerance. | |
| SmallVector< double, 1 > | donner::QuadraticYExtrema (const Vector2d &p0, const Vector2d &p1, const Vector2d &p2) |
| Find parameter values where the Y-derivative is zero for a quadratic Bezier curve. | |
| SmallVector< double, 2 > | donner::CubicYExtrema (const Vector2d &p0, const Vector2d &p1, const Vector2d &p2, const Vector2d &p3) |
| Find parameter values where the Y-derivative is zero for a cubic Bezier curve. | |
| Box2d | donner::QuadraticBounds (const Vector2d &p0, const Vector2d &p1, const Vector2d &p2) |
| Compute the tight axis-aligned bounding box of a quadratic Bezier curve. | |
| Box2d | donner::CubicBounds (const Vector2d &p0, const Vector2d &p1, const Vector2d &p2, const Vector2d &p3) |
| Compute the tight axis-aligned bounding box of a cubic Bezier curve. | |
Free functions for evaluating, splitting, approximating, and computing bounding boxes of quadratic and cubic Bezier curves.
These are used by the GPU rendering backend (Geode) for path processing.
| void donner::ApproximateCubicWithQuadratics | ( | const Vector2d & | p0, |
| const Vector2d & | p1, | ||
| const Vector2d & | p2, | ||
| const Vector2d & | p3, | ||
| double | tolerance, | ||
| std::vector< Vector2d > & | out ) |
Approximate a cubic Bezier curve as a sequence of quadratic Bezier curves within a given tolerance.
Appends quadratic control-point pairs (control, end) to out. The start point of each quadratic is the end point of the previous one (or p0 for the first). Uses recursive subdivision with a maximum depth of 10 to avoid infinite loops.
| p0 | Start point. | |
| p1 | First control point. | |
| p2 | Second control point. | |
| p3 | End point. | |
| tolerance | Maximum allowed distance between the cubic and its quadratic approximation. | |
| [out] | out | Output vector to which (control, end) point pairs are appended. |
| Box2d donner::CubicBounds | ( | const Vector2d & | p0, |
| const Vector2d & | p1, | ||
| const Vector2d & | p2, | ||
| const Vector2d & | p3 ) |
Compute the tight axis-aligned bounding box of a cubic Bezier curve.
Evaluates the curve at both X and Y extrema (not just the control-point hull) to produce the tightest axis-aligned bounds.
| p0 | Start point. |
| p1 | First control point. |
| p2 | Second control point. |
| p3 | End point. |
| SmallVector< double, 2 > donner::CubicYExtrema | ( | const Vector2d & | p0, |
| const Vector2d & | p1, | ||
| const Vector2d & | p2, | ||
| const Vector2d & | p3 ) |
Find parameter values where the Y-derivative is zero for a cubic Bezier curve.
These are the Y-monotonic split points. Returns 0, 1, or 2 parameter values in the open interval (0, 1), sorted in ascending order.
| p0 | Start point. |
| p1 | First control point. |
| p2 | Second control point. |
| p3 | End point. |
| Vector2d donner::EvalCubic | ( | const Vector2d & | p0, |
| const Vector2d & | p1, | ||
| const Vector2d & | p2, | ||
| const Vector2d & | p3, | ||
| double | t ) |
Evaluate a cubic Bezier curve at parameter t using the standard basis expansion.
\( B(t) = (1-t)^3 p_0 + 3t(1-t)^2 p_1 + 3t^2(1-t) p_2 + t^3 p_3 \)
| p0 | Start point. |
| p1 | First control point. |
| p2 | Second control point. |
| p3 | End point. |
| t | Parameter in [0, 1]. |
t. | Vector2d donner::EvalQuadratic | ( | const Vector2d & | p0, |
| const Vector2d & | p1, | ||
| const Vector2d & | p2, | ||
| double | t ) |
Evaluate a quadratic Bezier curve at parameter t using the standard basis expansion.
\( B(t) = (1-t)^2 p_0 + 2t(1-t) p_1 + t^2 p_2 \)
| p0 | Start point. |
| p1 | Control point. |
| p2 | End point. |
| t | Parameter in [0, 1]. |
t. Compute the tight axis-aligned bounding box of a quadratic Bezier curve.
Evaluates the curve at both X and Y extrema (not just the control-point hull) to produce the tightest axis-aligned bounds.
| p0 | Start point. |
| p1 | Control point. |
| p2 | End point. |
| SmallVector< double, 1 > donner::QuadraticYExtrema | ( | const Vector2d & | p0, |
| const Vector2d & | p1, | ||
| const Vector2d & | p2 ) |
Find parameter values where the Y-derivative is zero for a quadratic Bezier curve.
These are the Y-monotonic split points. Returns 0 or 1 parameter values in the open interval (0, 1).
| p0 | Start point. |
| p1 | Control point. |
| p2 | End point. |
| std::pair< std::array< Vector2d, 4 >, std::array< Vector2d, 4 > > donner::SplitCubic | ( | const Vector2d & | p0, |
| const Vector2d & | p1, | ||
| const Vector2d & | p2, | ||
| const Vector2d & | p3, | ||
| double | t ) |
Split a cubic Bezier curve at parameter t using De Casteljau subdivision.
Returns two cubic curves whose union equals the original curve.
| p0 | Start point. |
| p1 | First control point. |
| p2 | Second control point. |
| p3 | End point. |
| t | Split parameter in [0, 1]. |
| std::pair< std::array< Vector2d, 3 >, std::array< Vector2d, 3 > > donner::SplitQuadratic | ( | const Vector2d & | p0, |
| const Vector2d & | p1, | ||
| const Vector2d & | p2, | ||
| double | t ) |
Split a quadratic Bezier curve at parameter t using De Casteljau subdivision.
Returns two quadratic curves whose union equals the original curve.
| p0 | Start point. |
| p1 | Control point. |
| p2 | End point. |
| t | Split parameter in [0, 1]. |