]> git.mxchange.org Git - simgear.git/blob - simgear/math/sphrintp.h
Added simgear/magvar which impliments WMM 2000 world magnetic variance model.
[simgear.git] / simgear / math / sphrintp.h
1 /*
2   WARNING - Do not remove this header.
3
4   This code is a templated version of the 'magic-software' spherical
5   interpolation code by Dave Eberly. The original (un-hacked) code can be
6   obtained from here: http://www.magic-software.com/gr_appr.htm
7   This code is derived from linintp2.h/cpp and sphrintp.h/cpp.
8
9   Dave Eberly says that the conditions for use are:
10
11   * You may distribute the original source code to others at no charge.
12
13   * You may modify the original source code and distribute it to others at
14     no charge. The modified code must be documented to indicate that it is
15     not part of the original package.
16
17   * You may use this code for non-commercial purposes. You may also
18     incorporate this code into commercial packages. However, you may not
19     sell any of your source code which contains my original and/or modified
20     source code. In such a case, you need to factor out my code and freely
21     distribute it.
22
23   * The original code comes with absolutely no warranty and no guarantee is
24     made that the code is bug-free.
25
26   This does not seem incompatible with GPL - so this modified version
27   is hereby placed under GPL along with the rest of FlightGear.
28
29                               Christian Mayer
30 */
31
32 #ifndef SPHRINTP_H
33 #define SPHRINTP_H
34
35 #include "linintp2.h"
36 #include <plib/sg.h>
37
38 template<class T>
39 class SphereInterpolate
40 {
41 public:
42     SphereInterpolate (int n, const double* x, const double* y,
43         const double* z, const T* f);
44     SphereInterpolate (int n, const sgVec2* p, const T* f);
45    
46     ~SphereInterpolate ();
47     
48     void GetSphericalCoords (const double x, const double y, const double z,
49         double& thetaAngle, double& phiAngle) const;
50     
51     int Evaluate (const double x, const double y, const double z, T& f) const;
52     int Evaluate (const double thetaAngle, const double phiAngle, T& f) const;
53
54     T Evaluate(const sgVec2& p) const
55     {
56         T retval;
57         Evaluate(p[1], p[0], retval);
58         return retval;
59     }
60  
61     T Evaluate(const sgVec3& p) const
62     {
63         T retval;
64         Evaluate(p[1], p[0], retval);
65         return retval;
66     }
67
68 protected:
69     int numPoints;
70     double* theta;
71     double* phi;
72     T* func;
73     mgcLinInterp2D<T>* pInterp;
74 };
75
76 #include "sphrintp.inl"
77
78 #endif