qwt_bezier.h
Go to the documentation of this file.
1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
2  * Qwt Widget Library
3  * Copyright (C) 1997 Josef Wilgen
4  * Copyright (C) 2002 Uwe Rathmann
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the Qwt License, Version 1.0
8  *****************************************************************************/
9 
10 #ifndef QWT_BEZIER_H
11 #define QWT_BEZIER_H 1
12 
13 #include "qwt_global.h"
14 #include <qpolygon.h>
15 
28 {
29 public:
30  QwtBezier( double tolerance = 0.5 );
31  ~QwtBezier();
32 
33  void setTolerance( double tolerance );
34  double tolerance() const;
35 
36  QPolygonF toPolygon( const QPointF &p1, const QPointF &cp1,
37  const QPointF &cp2, const QPointF &p2 ) const;
38 
39  void appendToPolygon( const QPointF &p1, const QPointF &cp1,
40  const QPointF &cp2, const QPointF &p2, QPolygonF &polygon ) const;
41 
42  static QPointF pointAt( const QPointF &p1, const QPointF &cp1,
43  const QPointF &cp2, const QPointF &p2, double t );
44 
45 private:
46  double m_tolerance;
47  double m_flatness;
48 };
49 
54 inline double QwtBezier::tolerance() const
55 {
56  return m_tolerance;
57 }
58 
70 inline QPointF QwtBezier::pointAt( const QPointF &p1,
71  const QPointF &cp1, const QPointF &cp2, const QPointF &p2, double t )
72 {
73  const double d1 = 3.0 * t;
74  const double d2 = 3.0 * t * t;
75  const double d3 = t * t * t;
76  const double s = 1.0 - t;
77 
78  const double x = (( s * p1.x() + d1 * cp1.x() ) * s + d2 * cp2.x() ) * s + d3 * p2.x();
79  const double y = (( s * p1.y() + d1 * cp1.y() ) * s + d2 * cp2.y() ) * s + d3 * p2.y();
80 
81  return QPointF( x, y );
82 }
83 
84 #endif
double m_flatness
Definition: qwt_bezier.h:47
double m_tolerance
Definition: qwt_bezier.h:46
static QPointF pointAt(const QPointF &p1, const QPointF &cp1, const QPointF &cp2, const QPointF &p2, double t)
Definition: qwt_bezier.h:70
#define QWT_EXPORT
Definition: qwt_global.h:38
XmlRpcServer s
TFSIMD_FORCE_INLINE const tfScalar & y() const
An implementation of the de Casteljau’s Algorithm for interpolating Bézier curves.
Definition: qwt_bezier.h:27
TFSIMD_FORCE_INLINE const tfScalar & x() const
double tolerance() const
Definition: qwt_bezier.h:54


plotjuggler
Author(s): Davide Faconti
autogenerated on Sat Jul 6 2019 03:44:17