|
QWT API (English) 7.3.0
Qt Widget Library for Technical Applications - English API Documentation
|
An implementation of the de Casteljau's Algorithm for interpolating Bézier curves. More...
#include <qwt_bezier.h>
Public Member Functions | |
| QwtBezier (double tolerance=0.5) | |
| Constructor with tolerance parameter. | |
| ~QwtBezier () | |
| Destructor. | |
| void | setTolerance (double tolerance) |
| Set the tolerance for curve subdivision. | |
| double | tolerance () const |
| Get the tolerance value. | |
| QPolygonF | toPolygon (const QPointF &p1, const QPointF &cp1, const QPointF &cp2, const QPointF &p2) const |
| Interpolate a Bézier curve as a polygon. | |
| void | appendToPolygon (const QPointF &p1, const QPointF &cp1, const QPointF &cp2, const QPointF &p2, QPolygonF &polygon) const |
| Append Bézier curve points to an existing polygon. | |
Static Public Member Functions | |
| static QPointF | pointAt (const QPointF &p1, const QPointF &cp1, const QPointF &cp2, const QPointF &p2, double t) |
| Find a point on a Bézier curve at parameter t. | |
An implementation of the de Casteljau's Algorithm for interpolating Bézier curves.
The flatness criterion for terminating the subdivision is based on "Piecewise Linear Approximation of Bézier Curves" by Roger Willcocks. See: https://jeremykun.com/2013/05/11/bezier-curves-and-picasso
| QwtBezier::QwtBezier | ( | double | tolerance = 0.5 | ) |
Constructor with tolerance parameter.
Constructor.
| tolerance | Termination criterion for the subdivision |
| void QwtBezier::appendToPolygon | ( | const QPointF & | p1, |
| const QPointF & | cp1, | ||
| const QPointF & | cp2, | ||
| const QPointF & | p2, | ||
| QPolygonF & | polygon | ||
| ) | const |
Append Bézier curve points to an existing polygon.
Interpolate a Bézier curve by adding points to a polygon.
appendToPolygon() is tailored for accumulating points from a sequence of Bézier curves, such as those created by spline interpolation.
| p1 | Start point |
| cp1 | First control point |
| cp2 | Second control point |
| p2 | End point |
| polygon | Polygon where the interpolating points are added |
|
static |
Find a point on a Bézier curve at parameter t.
Find a point on a Bézier curve.
| p1 | Start point |
| cp1 | First control point |
| cp2 | Second control point |
| p2 | End point |
| t | Parameter value in range [0,1] |
| void QwtBezier::setTolerance | ( | double | tolerance | ) |
Set the tolerance for curve subdivision.
The tolerance is a measurement for the flatness of a curve. A curve with a flatness below the tolerance is considered as being flat, terminating the subdivision algorithm. When interpolating a Bezier curve to render it as a sequence of lines to some sort of raster (e.g., to screen), a value of 0.5 of the pixel size is a good value for the tolerance.
| tolerance | Termination criterion for the subdivision |
|
inline |
Get the tolerance value.
| QPolygonF QwtBezier::toPolygon | ( | const QPointF & | p1, |
| const QPointF & | cp1, | ||
| const QPointF & | cp2, | ||
| const QPointF & | p2 | ||
| ) | const |
Interpolate a Bézier curve as a polygon.
Interpolate a Bézier curve by a polygon.
| p1 | Start point |
| cp1 | First control point |
| cp2 | Second control point |
| p2 | End point |