qwt_spline_polynomial.h
Go to the documentation of this file.
1 /******************************************************************************
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_SPLINE_POLYNOMIAL_H
11 #define QWT_SPLINE_POLYNOMIAL_H
12 
13 #include "qwt_global.h"
14 
15 #include <qpoint.h>
16 #include <qmetatype.h>
17 
31 {
32  public:
33  QwtSplinePolynomial( double c3 = 0.0, double c2 = 0.0, double c1 = 0.0 );
34 
35  bool operator==( const QwtSplinePolynomial& ) const;
36  bool operator!=( const QwtSplinePolynomial& ) const;
37 
38  double valueAt( double x ) const;
39  double slopeAt( double x ) const;
40  double curvatureAt( double x ) const;
41 
42  static QwtSplinePolynomial fromSlopes(
43  const QPointF& p1, double m1,
44  const QPointF& p2, double m2 );
45 
46  static QwtSplinePolynomial fromSlopes(
47  double x, double y, double m1, double m2 );
48 
49  static QwtSplinePolynomial fromCurvatures(
50  const QPointF& p1, double cv1,
51  const QPointF& p2, double cv2 );
52 
53  static QwtSplinePolynomial fromCurvatures(
54  double dx, double dy, double cv1, double cv2 );
55 
56  public:
58  double c3;
59 
61  double c2;
62 
64  double c1;
65 };
66 
67 Q_DECLARE_TYPEINFO( QwtSplinePolynomial, Q_MOVABLE_TYPE );
68 Q_DECLARE_METATYPE( QwtSplinePolynomial )
69 
70 
77 inline QwtSplinePolynomial::QwtSplinePolynomial( double a3, double a2, double a1 )
78  : c3( a3 )
79  , c2( a2 )
80  , c1( a1 )
81 {
82 }
83 
88 inline bool QwtSplinePolynomial::operator==( const QwtSplinePolynomial& other ) const
89 {
90  return ( c3 == other.c3 ) && ( c2 == other.c2 ) && ( c1 == other.c1 );
91 }
92 
97 inline bool QwtSplinePolynomial::operator!=( const QwtSplinePolynomial& other ) const
98 {
99  return ( !( *this == other ) );
100 }
101 
108 inline double QwtSplinePolynomial::valueAt( double x ) const
109 {
110  return ( ( ( c3 * x ) + c2 ) * x + c1 ) * x;
111 }
112 
119 inline double QwtSplinePolynomial::slopeAt( double x ) const
120 {
121  return ( 3.0 * c3 * x + 2.0 * c2 ) * x + c1;
122 }
123 
130 inline double QwtSplinePolynomial::curvatureAt( double x ) const
131 {
132  return 6.0 * c3 * x + 2.0 * c2;
133 }
134 
148  const QPointF& p1, double m1, const QPointF& p2, double m2 )
149 {
150  return fromSlopes( p2.x() - p1.x(), p2.y() - p1.y(), m1, m2 );
151 }
152 
165  double dx, double dy, double m1, double m2 )
166 {
167  const double c2 = ( 3.0 * dy / dx - 2 * m1 - m2 ) / dx;
168  const double c3 = ( ( m2 - m1 ) / dx - 2.0 * c2 ) / ( 3.0 * dx );
169 
170  return QwtSplinePolynomial( c3, c2, m1 );
171 }
172 
186  const QPointF& p1, double cv1, const QPointF& p2, double cv2 )
187 {
188  return fromCurvatures( p2.x() - p1.x(), p2.y() - p1.y(), cv1, cv2 );
189 }
190 
203  double dx, double dy, double cv1, double cv2 )
204 {
205  const double c3 = ( cv2 - cv1 ) / ( 6.0 * dx );
206  const double c2 = 0.5 * cv1;
207  const double c1 = dy / dx - ( c3 * dx + c2 ) * dx;
208 
209  return QwtSplinePolynomial( c3, c2, c1 );
210 }
211 
212 #ifndef QT_NO_DEBUG_STREAM
213 
214 class QDebug;
215 QWT_EXPORT QDebug operator<<( QDebug, const QwtSplinePolynomial& );
216 
217 #endif
218 
219 #endif
QwtSplinePolynomial::slopeAt
double slopeAt(double x) const
Definition: qwt_spline_polynomial.h:119
QwtSplinePolynomial::operator==
bool operator==(const QwtSplinePolynomial &) const
Definition: qwt_spline_polynomial.h:88
QwtSplinePolynomial
A cubic polynomial without constant term.
Definition: qwt_spline_polynomial.h:30
QwtSplinePolynomial::QwtSplinePolynomial
QwtSplinePolynomial(double c3=0.0, double c2=0.0, double c1=0.0)
Constructor.
Definition: qwt_spline_polynomial.h:77
QwtSplinePolynomial::fromCurvatures
static QwtSplinePolynomial fromCurvatures(const QPointF &p1, double cv1, const QPointF &p2, double cv2)
Definition: qwt_spline_polynomial.h:185
QwtSplinePolynomial::c2
double c2
coefficient of the quadratic summand
Definition: qwt_spline_polynomial.h:68
qwt_global.h
QwtSplinePolynomial::c3
double c3
coefficient of the cubic summand
Definition: qwt_spline_polynomial.h:65
mqtt_test_proto.x
x
Definition: mqtt_test_proto.py:34
Q_DECLARE_TYPEINFO
Q_DECLARE_TYPEINFO(QwtSplinePolynomial, Q_MOVABLE_TYPE)
mqtt_test_proto.y
y
Definition: mqtt_test_proto.py:35
QwtSplinePolynomial::fromSlopes
static QwtSplinePolynomial fromSlopes(const QPointF &p1, double m1, const QPointF &p2, double m2)
Definition: qwt_spline_polynomial.h:147
QwtSplinePolynomial::operator!=
bool operator!=(const QwtSplinePolynomial &) const
Definition: qwt_spline_polynomial.h:97
QwtSplinePolynomial::curvatureAt
double curvatureAt(double x) const
Definition: qwt_spline_polynomial.h:130
operator==
bool operator==(QwtEventPattern::MousePattern b1, QwtEventPattern::MousePattern b2)
Compare operator.
Definition: qwt_event_pattern.h:228
sol::operator!=
constexpr bool operator!=(const optional< T > &lhs, const optional< U > &rhs)
\group relop
Definition: sol.hpp:6020
QWT_EXPORT
#define QWT_EXPORT
Definition: qwt_global.h:38
QwtSplinePolynomial::valueAt
double valueAt(double x) const
Definition: qwt_spline_polynomial.h:108
QwtSplinePolynomial::c1
double c1
coefficient of the linear summand
Definition: qwt_spline_polynomial.h:71
operator<<
QWT_EXPORT QDebug operator<<(QDebug, const QwtSplinePolynomial &)
Definition: qwt_spline_polynomial.cpp:26


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:46