QWT API (中文) 7.0.1
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
qwt_spline_polynomial.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 * Modified by ChenZongYan in 2024 <czy.t@163.com>
10 * Summary of major modifications (see ChangeLog.md for full history):
11 * 1. CMake build system & C++11 throughout.
12 * 2. Core panner/ zoomer refactored:
13 * - QwtPanner → QwtCachePanner (pixmap-cache version)
14 * - New real-time QwtPlotPanner derived from QwtPicker.
15 * 3. Zoomer supports multi-axis.
16 * 4. Parasite-plot framework:
17 * - QwtFigure, QwtPlotParasiteLayout, QwtPlotTransparentCanvas,
18 * - QwtPlotScaleEventDispatcher, built-in pan/zoom on axis.
19 * 5. New picker: QwtPlotSeriesDataPicker (works with date axis).
20 * 6. Raster & color-map extensions:
21 * - QwtGridRasterData (2-D table + interpolation)
22 * - QwtLinearColorMap::stopColors(), stopPos() API rename.
23 * 7. Bar-chart: expose pen/brush control.
24 * 8. Amalgamated build: single QwtPlot.h / QwtPlot.cpp pair in src-amalgamate.
25 *****************************************************************************/
26
27#ifndef QWT_SPLINE_POLYNOMIAL_H
28#define QWT_SPLINE_POLYNOMIAL_H
29
30#include "qwt_global.h"
31
32#include <qpoint.h>
33#include <qmetatype.h>
34
61class QWT_EXPORT QwtSplinePolynomial
62{
63 public:
64 QwtSplinePolynomial( double c3 = 0.0, double c2 = 0.0, double c1 = 0.0 );
65
66 bool operator==( const QwtSplinePolynomial& ) const;
67 bool operator!=( const QwtSplinePolynomial& ) const;
68
69 double valueAt( double x ) const;
70 double slopeAt( double x ) const;
71 double curvatureAt( double x ) const;
72
73 static QwtSplinePolynomial fromSlopes(
74 const QPointF& p1, double m1,
75 const QPointF& p2, double m2 );
76
77 static QwtSplinePolynomial fromSlopes(
78 double x, double y, double m1, double m2 );
79
80 static QwtSplinePolynomial fromCurvatures(
81 const QPointF& p1, double cv1,
82 const QPointF& p2, double cv2 );
83
84 static QwtSplinePolynomial fromCurvatures(
85 double dx, double dy, double cv1, double cv2 );
86
87 public:
89 double c3;
90
92 double c2;
93
95 double c1;
96};
97
98Q_DECLARE_TYPEINFO( QwtSplinePolynomial, Q_MOVABLE_TYPE );
99Q_DECLARE_METATYPE( QwtSplinePolynomial )
100
101
118inline QwtSplinePolynomial::QwtSplinePolynomial( double a3, double a2, double a1 )
119 : c3( a3 )
120 , c2( a2 )
121 , c1( a1 )
122{
123}
124
141{
142 return ( c3 == other.c3 ) && ( c2 == other.c2 ) && ( c1 == other.c1 );
143}
144
161{
162 return ( !( *this == other ) );
163}
164
180inline double QwtSplinePolynomial::valueAt( double x ) const
181{
182 return ( ( ( c3 * x ) + c2 ) * x + c1 ) * x;
183}
184
200inline double QwtSplinePolynomial::slopeAt( double x ) const
201{
202 return ( 3.0 * c3 * x + 2.0 * c2 ) * x + c1;
203}
204
220inline double QwtSplinePolynomial::curvatureAt( double x ) const
221{
222 return 6.0 * c3 * x + 2.0 * c2;
223}
224
252 const QPointF& p1, double m1, const QPointF& p2, double m2 )
253{
254 return fromSlopes( p2.x() - p1.x(), p2.y() - p1.y(), m1, m2 );
255}
256
282 double dx, double dy, double m1, double m2 )
283{
284 const double c2 = ( 3.0 * dy / dx - 2 * m1 - m2 ) / dx;
285 const double c3 = ( ( m2 - m1 ) / dx - 2.0 * c2 ) / ( 3.0 * dx );
286
287 return QwtSplinePolynomial( c3, c2, m1 );
288}
289
317 const QPointF& p1, double cv1, const QPointF& p2, double cv2 )
318{
319 return fromCurvatures( p2.x() - p1.x(), p2.y() - p1.y(), cv1, cv2 );
320}
321
347 double dx, double dy, double cv1, double cv2 )
348{
349 const double c3 = ( cv2 - cv1 ) / ( 6.0 * dx );
350 const double c2 = 0.5 * cv1;
351 const double c1 = dy / dx - ( c3 * dx + c2 ) * dx;
352
353 return QwtSplinePolynomial( c3, c2, c1 );
354}
355
356#ifndef QT_NO_DEBUG_STREAM
357
358class QDebug;
359QWT_EXPORT QDebug operator<<( QDebug, const QwtSplinePolynomial& );
360
361#endif
362
363#endif
无常数项的三次多项式
Definition qwt_spline_polynomial.h:62
double slopeAt(double x) const
计算给定 x 处多项式的一阶导数值
Definition qwt_spline_polynomial.h:200
static QwtSplinePolynomial fromSlopes(const QPointF &p1, double m1, const QPointF &p2, double m2)
找出包含两个点及其一阶导数值的多项式系数
Definition qwt_spline_polynomial.h:251
double valueAt(double x) const
计算给定 x 处的多项式值
Definition qwt_spline_polynomial.h:180
bool operator==(const QwtSplinePolynomial &) const
比较两个多项式是否相等
Definition qwt_spline_polynomial.h:140
static QwtSplinePolynomial fromCurvatures(const QPointF &p1, double cv1, const QPointF &p2, double cv2)
找出包含两个点及其二阶导数值的多项式系数
Definition qwt_spline_polynomial.h:316
bool operator!=(const QwtSplinePolynomial &) const
比较两个多项式是否不相等
Definition qwt_spline_polynomial.h:160
double c1
coefficient of the linear summand
Definition qwt_spline_polynomial.h:95
double c3
coefficient of the cubic summand
Definition qwt_spline_polynomial.h:89
double c2
coefficient of the quadratic summand
Definition qwt_spline_polynomial.h:92
double curvatureAt(double x) const
计算给定 x 处多项式的二阶导数值
Definition qwt_spline_polynomial.h:220