source: ntrip/trunk/BNC/qwt/qwt_spline.h@ 10126

Last change on this file since 10126 was 4271, checked in by mervart, 12 years ago
File size: 2.4 KB
Line 
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_SPLINE_H
11#define QWT_SPLINE_H
12
13#include "qwt_global.h"
14#include <qpolygon.h>
15#include <qvector.h>
16
17/*!
18 \brief A class for spline interpolation
19
20 The QwtSpline class is used for cubical spline interpolation.
21 Two types of splines, natural and periodic, are supported.
22
23 \par Usage:
24 <ol>
25 <li>First call setPoints() to determine the spline coefficients
26 for a tabulated function y(x).
27 <li>After the coefficients have been set up, the interpolated
28 function value for an argument x can be determined by calling
29 QwtSpline::value().
30 </ol>
31
32 \par Example:
33 \code
34#include <qwt_spline.h>
35
36QPolygonF interpolate(const QPolygonF& points, int numValues)
37{
38 QwtSpline spline;
39 if ( !spline.setPoints(points) )
40 return points;
41
42 QPolygonF interpolatedPoints(numValues);
43
44 const double delta =
45 (points[numPoints - 1].x() - points[0].x()) / (points.size() - 1);
46 for(i = 0; i < points.size(); i++) / interpolate
47 {
48 const double x = points[0].x() + i * delta;
49 interpolatedPoints[i].setX(x);
50 interpolatedPoints[i].setY(spline.value(x));
51 }
52 return interpolatedPoints;
53}
54 \endcode
55*/
56
57class QWT_EXPORT QwtSpline
58{
59public:
60 //! Spline type
61 enum SplineType
62 {
63 //! A natural spline
64 Natural,
65
66 //! A periodic spline
67 Periodic
68 };
69
70 QwtSpline();
71 QwtSpline( const QwtSpline & );
72
73 ~QwtSpline();
74
75 QwtSpline &operator=( const QwtSpline & );
76
77 void setSplineType( SplineType );
78 SplineType splineType() const;
79
80 bool setPoints( const QPolygonF& points );
81 QPolygonF points() const;
82
83 void reset();
84
85 bool isValid() const;
86 double value( double x ) const;
87
88 const QVector<double> &coefficientsA() const;
89 const QVector<double> &coefficientsB() const;
90 const QVector<double> &coefficientsC() const;
91
92protected:
93 bool buildNaturalSpline( const QPolygonF & );
94 bool buildPeriodicSpline( const QPolygonF & );
95
96private:
97 class PrivateData;
98 PrivateData *d_data;
99};
100
101#endif
Note: See TracBrowser for help on using the repository browser.