Public Member Functions | Static Public Member Functions | Private Attributes
QwtBezier Class Reference

An implementation of the de Casteljau’s Algorithm for interpolating Bézier curves. More...

#include <qwt_bezier.h>

List of all members.

Public Member Functions

void appendToPolygon (const QPointF &p1, const QPointF &cp1, const QPointF &cp2, const QPointF &p2, QPolygonF &polygon) const
 Interpolate a Bézier curve by a polygon.
 QwtBezier (double tolerance=0.5)
 Constructor.
void setTolerance (double tolerance)
double tolerance () const
QPolygonF toPolygon (const QPointF &p1, const QPointF &cp1, const QPointF &cp2, const QPointF &p2) const
 Interpolate a Bézier curve by a polygon.
 ~QwtBezier ()
 Destructor.

Static Public Member Functions

static QPointF pointAt (const QPointF &p1, const QPointF &cp1, const QPointF &cp2, const QPointF &p2, double t)

Private Attributes

double m_flatness
double m_tolerance

Detailed Description

An implementation of the de Casteljau’s Algorithm for interpolating Bézier curves.

The flatness criterion for terminating the subdivison is based on "Piecewise Linear Approximation of Bézier Curves" by Roger Willcocks ( http://www.rops.org )

This article explains the maths behind in a very nice way: https://jeremykun.com/2013/05/11/bezier-curves-and-picasso

Definition at line 27 of file qwt_bezier.h.


Constructor & Destructor Documentation

QwtBezier::QwtBezier ( double  tolerance = 0.5)

Constructor.

Parameters:
toleranceTermination criterion for the subdivision
See also:
setTolerance()

Definition at line 113 of file qwt_bezier.cpp.

Destructor.

Definition at line 120 of file qwt_bezier.cpp.


Member Function Documentation

void QwtBezier::appendToPolygon ( const QPointF &  p1,
const QPointF &  cp1,
const QPointF &  cp2,
const QPointF &  p2,
QPolygonF &  polygon 
) const

Interpolate a Bézier curve by a polygon.

appendToPolygon() is tailored for cummulating points from a sequence of bezier curves like being created by a spline interpolation.

Parameters:
p1Start point
cp1First control point
cp2Second control point
p2End point
polygonPolygon, where the interpolating points are added
Note:
If the last point of the incoming polygon matches p1 it won't be inserted a second time.

Definition at line 183 of file qwt_bezier.cpp.

QPointF QwtBezier::pointAt ( const QPointF &  p1,
const QPointF &  cp1,
const QPointF &  cp2,
const QPointF &  p2,
double  t 
) [inline, static]

Find a point on a Bézier Curve

Parameters:
p1Start point
cp1First control point
cp2Second control point
p2End point
tParameter value, something between [0,1]
Returns:
Point on the curve

Definition at line 70 of file qwt_bezier.h.

void QwtBezier::setTolerance ( double  tolerance)

Set the tolerance

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 algorith.

When interpolating a Betier curve to render it as a sequence of lines to some sort of raster ( f.e to screen ) a value of 0.5 of the pixel size is a good value for the tolerance.

Parameters:
toleranceTermination criterion for the subdivision
See also:
tolerance()

Definition at line 138 of file qwt_bezier.cpp.

double QwtBezier::tolerance ( ) const [inline]
Returns:
Tolerance, that is used as criterion for the subdivisn
See also:
setTolerance()

Definition at line 54 of file qwt_bezier.h.

QPolygonF QwtBezier::toPolygon ( const QPointF &  p1,
const QPointF &  cp1,
const QPointF &  cp2,
const QPointF &  p2 
) const

Interpolate a Bézier curve by a polygon.

Parameters:
p1Start point
cp1First control point
cp2Second control point
p2End point
Returns:
Interpolating polygon

Definition at line 154 of file qwt_bezier.cpp.


Member Data Documentation

double QwtBezier::m_flatness [private]

Definition at line 47 of file qwt_bezier.h.

double QwtBezier::m_tolerance [private]

Definition at line 46 of file qwt_bezier.h.


The documentation for this class was generated from the following files:


plotjuggler
Author(s): Davide Faconti
autogenerated on Fri Sep 1 2017 02:41:57