23 inline BezierData(
const QPointF &p1,
const QPointF &cp1,
24 const QPointF &cp2,
const QPointF &p2 ):
36 static inline double minFlatness(
double tolerance )
42 return 16 * ( tolerance * tolerance );
45 inline double flatness()
const 49 const double ux = 3.0 * d_cx1 - 2.0 * d_x1 - d_x2;
50 const double uy = 3.0 * d_cy1 - 2.0 * d_y1 - d_y2;
51 const double vx = 3.0 * d_cx2 - 2.0 * d_x2 - d_x1;
52 const double vy = 3.0 * d_cy2 - 2.0 * d_y2 - d_y1;
54 const double ux2 = ux * ux;
55 const double uy2 = uy * uy;
57 const double vx2 = vx * vx;
58 const double vy2 = vy * vy;
60 return qMax( ux2, vx2 ) + qMax( uy2, vy2 );
63 inline BezierData subdivided()
67 const double c1 = midValue( d_cx1, d_cx2 );
69 bz.d_cx1 = midValue( d_x1, d_cx1 );
70 d_cx2 = midValue( d_cx2, d_x2 );
72 bz.d_cx2 = midValue( bz.d_cx1, c1 );
73 d_cx1 = midValue( c1, d_cx2 );
74 bz.d_x2 = d_x1 = midValue( bz.d_cx2, d_cx1 );
76 const double c2 = midValue( d_cy1, d_cy2 );
78 bz.d_cy1 = midValue( d_y1, d_cy1 );
79 d_cy2 = midValue( d_cy2, d_y2 );
81 bz.d_cy2 = midValue( bz.d_cy1, c2 );
82 d_cy1 = midValue( d_cy2, c2 );
83 bz.d_y2 = d_y1 = midValue( bz.d_cy2, d_cy1 );
88 inline QPointF p2()
const 90 return QPointF( d_x2, d_y2 );
94 inline double midValue(
double v1,
double v2 )
96 return 0.5 * ( v1 + v2 );
114 m_tolerance( qMax( tolerance, 0.0 ) ),
115 m_flatness( BezierData::minFlatness( m_tolerance ) )
155 const QPointF &cp1,
const QPointF &cp2,
const QPointF &p2 )
const 184 const QPointF &cp2,
const QPointF &p2, QPolygonF &polygon )
const 192 if ( polygon.isEmpty() || polygon.last() != p1 )
200 stack.push( BezierData( p1, cp1, cp2, p2 ) );
204 BezierData &bz = stack.top();
208 if ( stack.size() == 1 )
219 stack.push( bz.subdivided() );
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.
void setTolerance(double tolerance)
TFSIMD_FORCE_INLINE const tfScalar & y() const
QwtBezier(double tolerance=0.5)
Constructor.
TFSIMD_FORCE_INLINE const tfScalar & x() const
QPolygonF toPolygon(const QPointF &p1, const QPointF &cp1, const QPointF &cp2, const QPointF &p2) const
Interpolate a Bézier curve by a polygon.