Qwt User's Guide 6.2.0

qwt_spline_parametrization.h
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_PARAMETRIZATION_H
11 #define QWT_SPLINE_PARAMETRIZATION_H
12
13 #include "qwt_global.h"
14 #include "qwt_math.h"
15
16 #include <qpoint.h>
17
44 class QWT_EXPORT QwtSplineParametrization
45 {
46 public:
48 enum Type
49 {
54 ParameterX,
55
60 ParameterY,
61
72 ParameterUniform,
73
82 ParameterChordal,
83
94 ParameterCentripetal,
95
96
105 ParameterManhattan
106 };
107
108 explicit QwtSplineParametrization( int type );
109 virtual ~QwtSplineParametrization();
110
111 int type() const;
112
113 virtual double valueIncrement( const QPointF&, const QPointF& ) const;
114
115 static double valueIncrementX( const QPointF&, const QPointF& );
116 static double valueIncrementY( const QPointF&, const QPointF& );
117 static double valueIncrementUniform( const QPointF&, const QPointF& );
118 static double valueIncrementChordal( const QPointF&, const QPointF& );
119 static double valueIncrementCentripetal( const QPointF&, const QPointF& );
120 static double valueIncrementManhattan( const QPointF&, const QPointF& );
121
122 private:
123 const int m_type;
124 };
125
134 inline double QwtSplineParametrization::valueIncrementX(
135 const QPointF& point1, const QPointF& point2 )
136 {
137 return point2.x() - point1.x();
138 }
139
148 inline double QwtSplineParametrization::valueIncrementY(
149 const QPointF& point1, const QPointF& point2 )
150 {
151 return point2.y() - point1.y();
152 }
153
162 inline double QwtSplineParametrization::valueIncrementUniform(
163 const QPointF& point1, const QPointF& point2 )
164 {
165 Q_UNUSED( point1 )
166 Q_UNUSED( point2 )
167
168 return 1.0;
169 }
170
179 inline double QwtSplineParametrization::valueIncrementChordal(
180 const QPointF& point1, const QPointF& point2 )
181 {
182 const double dx = point2.x() - point1.x();
183 const double dy = point2.y() - point1.y();
184
185 return std::sqrt( dx * dx + dy * dy );
186 }
187
196 inline double QwtSplineParametrization::valueIncrementCentripetal(
197 const QPointF& point1, const QPointF& point2 )
198 {
199 return std::sqrt( valueIncrementChordal( point1, point2 ) );
200 }
201
210 inline double QwtSplineParametrization::valueIncrementManhattan(
211 const QPointF& point1, const QPointF& point2 )
212 {
213 return qAbs( point2.x() - point1.x() ) + qAbs( point2.y() - point1.y() );
214 }
215
216 #endif
QwtSplineParametrization
Curve parametrization used for a spline interpolation.
Definition: qwt_spline_parametrization.h:45
QwtSplineParametrization::valueIncrementChordal
static double valueIncrementChordal(const QPointF &, const QPointF &)
Calculate the ParameterChordal value increment for 2 points.
Definition: qwt_spline_parametrization.h:179
QwtSplineParametrization::valueIncrementCentripetal
static double valueIncrementCentripetal(const QPointF &, const QPointF &)
Calculate the ParameterCentripetal value increment for 2 points.
Definition: qwt_spline_parametrization.h:196
QwtSplineParametrization::valueIncrementX
static double valueIncrementX(const QPointF &, const QPointF &)
Calculate the ParameterX value increment for 2 points.
Definition: qwt_spline_parametrization.h:134
QwtSplineParametrization::valueIncrementUniform
static double valueIncrementUniform(const QPointF &, const QPointF &)
Calculate the ParameterUniform value increment.
Definition: qwt_spline_parametrization.h:162
QwtSplineParametrization::Type
Type
Parametrization type.
Definition: qwt_spline_parametrization.h:49
QwtSplineParametrization::ParameterY
@ ParameterY
Definition: qwt_spline_parametrization.h:60
QwtSplineParametrization::ParameterCentripetal
@ ParameterCentripetal
Definition: qwt_spline_parametrization.h:94
QwtSplineParametrization::ParameterX
@ ParameterX
Definition: qwt_spline_parametrization.h:54
QwtSplineParametrization::ParameterUniform
@ ParameterUniform
Definition: qwt_spline_parametrization.h:72
QwtSplineParametrization::ParameterChordal
@ ParameterChordal
Definition: qwt_spline_parametrization.h:82
QwtSplineParametrization::valueIncrementManhattan
static double valueIncrementManhattan(const QPointF &, const QPointF &)
Calculate the ParameterManhattan value increment for 2 points.
Definition: qwt_spline_parametrization.h:210
QwtSplineParametrization::valueIncrementY
static double valueIncrementY(const QPointF &, const QPointF &)
Calculate the ParameterY value increment for 2 points.
Definition: qwt_spline_parametrization.h:148