geographiclib 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +7 -0
  2. data/AUTHORS +12 -0
  3. data/LICENSE +24 -0
  4. data/ext/geographiclib/Accumulator.cpp +23 -0
  5. data/ext/geographiclib/AlbersEqualArea.cpp +445 -0
  6. data/ext/geographiclib/AzimuthalEquidistant.cpp +41 -0
  7. data/ext/geographiclib/CassiniSoldner.cpp +89 -0
  8. data/ext/geographiclib/CircularEngine.cpp +96 -0
  9. data/ext/geographiclib/DMS.cpp +381 -0
  10. data/ext/geographiclib/Ellipsoid.cpp +125 -0
  11. data/ext/geographiclib/EllipticFunction.cpp +512 -0
  12. data/ext/geographiclib/GARS.cpp +122 -0
  13. data/ext/geographiclib/GeoCoords.cpp +175 -0
  14. data/ext/geographiclib/Geocentric.cpp +172 -0
  15. data/ext/geographiclib/Geodesic.cpp +1908 -0
  16. data/ext/geographiclib/GeodesicExact.cpp +927 -0
  17. data/ext/geographiclib/GeodesicExactC4.cpp +7879 -0
  18. data/ext/geographiclib/GeodesicLine.cpp +321 -0
  19. data/ext/geographiclib/GeodesicLineExact.cpp +289 -0
  20. data/ext/geographiclib/GeographicLib/Accumulator.hpp +184 -0
  21. data/ext/geographiclib/GeographicLib/AlbersEqualArea.hpp +312 -0
  22. data/ext/geographiclib/GeographicLib/AzimuthalEquidistant.hpp +139 -0
  23. data/ext/geographiclib/GeographicLib/CassiniSoldner.hpp +204 -0
  24. data/ext/geographiclib/GeographicLib/CircularEngine.hpp +195 -0
  25. data/ext/geographiclib/GeographicLib/Config.h +12 -0
  26. data/ext/geographiclib/GeographicLib/Constants.hpp +387 -0
  27. data/ext/geographiclib/GeographicLib/DMS.hpp +370 -0
  28. data/ext/geographiclib/GeographicLib/Ellipsoid.hpp +534 -0
  29. data/ext/geographiclib/GeographicLib/EllipticFunction.hpp +692 -0
  30. data/ext/geographiclib/GeographicLib/GARS.hpp +143 -0
  31. data/ext/geographiclib/GeographicLib/GeoCoords.hpp +544 -0
  32. data/ext/geographiclib/GeographicLib/Geocentric.hpp +267 -0
  33. data/ext/geographiclib/GeographicLib/Geodesic.hpp +970 -0
  34. data/ext/geographiclib/GeographicLib/GeodesicExact.hpp +862 -0
  35. data/ext/geographiclib/GeographicLib/GeodesicLine.hpp +701 -0
  36. data/ext/geographiclib/GeographicLib/GeodesicLineExact.hpp +667 -0
  37. data/ext/geographiclib/GeographicLib/Geohash.hpp +180 -0
  38. data/ext/geographiclib/GeographicLib/Geoid.hpp +472 -0
  39. data/ext/geographiclib/GeographicLib/Georef.hpp +160 -0
  40. data/ext/geographiclib/GeographicLib/Gnomonic.hpp +206 -0
  41. data/ext/geographiclib/GeographicLib/GravityCircle.hpp +301 -0
  42. data/ext/geographiclib/GeographicLib/GravityModel.hpp +520 -0
  43. data/ext/geographiclib/GeographicLib/LambertConformalConic.hpp +313 -0
  44. data/ext/geographiclib/GeographicLib/LocalCartesian.hpp +236 -0
  45. data/ext/geographiclib/GeographicLib/MGRS.hpp +355 -0
  46. data/ext/geographiclib/GeographicLib/MagneticCircle.hpp +178 -0
  47. data/ext/geographiclib/GeographicLib/MagneticModel.hpp +347 -0
  48. data/ext/geographiclib/GeographicLib/Math.hpp +920 -0
  49. data/ext/geographiclib/GeographicLib/NormalGravity.hpp +350 -0
  50. data/ext/geographiclib/GeographicLib/OSGB.hpp +249 -0
  51. data/ext/geographiclib/GeographicLib/PolarStereographic.hpp +150 -0
  52. data/ext/geographiclib/GeographicLib/PolygonArea.hpp +288 -0
  53. data/ext/geographiclib/GeographicLib/Rhumb.hpp +589 -0
  54. data/ext/geographiclib/GeographicLib/SphericalEngine.hpp +376 -0
  55. data/ext/geographiclib/GeographicLib/SphericalHarmonic.hpp +354 -0
  56. data/ext/geographiclib/GeographicLib/SphericalHarmonic1.hpp +281 -0
  57. data/ext/geographiclib/GeographicLib/SphericalHarmonic2.hpp +315 -0
  58. data/ext/geographiclib/GeographicLib/TransverseMercator.hpp +196 -0
  59. data/ext/geographiclib/GeographicLib/TransverseMercatorExact.hpp +254 -0
  60. data/ext/geographiclib/GeographicLib/UTMUPS.hpp +421 -0
  61. data/ext/geographiclib/GeographicLib/Utility.hpp +612 -0
  62. data/ext/geographiclib/Geohash.cpp +102 -0
  63. data/ext/geographiclib/Geoid.cpp +509 -0
  64. data/ext/geographiclib/Georef.cpp +135 -0
  65. data/ext/geographiclib/Gnomonic.cpp +85 -0
  66. data/ext/geographiclib/GravityCircle.cpp +129 -0
  67. data/ext/geographiclib/GravityModel.cpp +360 -0
  68. data/ext/geographiclib/LambertConformalConic.cpp +456 -0
  69. data/ext/geographiclib/LocalCartesian.cpp +62 -0
  70. data/ext/geographiclib/MGRS.cpp +461 -0
  71. data/ext/geographiclib/MagneticCircle.cpp +52 -0
  72. data/ext/geographiclib/MagneticModel.cpp +269 -0
  73. data/ext/geographiclib/Math.cpp +63 -0
  74. data/ext/geographiclib/NormalGravity.cpp +262 -0
  75. data/ext/geographiclib/OSGB.cpp +167 -0
  76. data/ext/geographiclib/PolarStereographic.cpp +108 -0
  77. data/ext/geographiclib/PolygonArea.cpp +204 -0
  78. data/ext/geographiclib/Rhumb.cpp +383 -0
  79. data/ext/geographiclib/SphericalEngine.cpp +477 -0
  80. data/ext/geographiclib/TransverseMercator.cpp +603 -0
  81. data/ext/geographiclib/TransverseMercatorExact.cpp +464 -0
  82. data/ext/geographiclib/UTMUPS.cpp +296 -0
  83. data/ext/geographiclib/Utility.cpp +61 -0
  84. data/ext/geographiclib/extconf.rb +3 -0
  85. data/ext/geographiclib/geographiclib.cpp +62 -0
  86. data/lib/geographiclib.rb +20 -0
  87. metadata +140 -0
@@ -0,0 +1,139 @@
1
+ /**
2
+ * \file AzimuthalEquidistant.hpp
3
+ * \brief Header for GeographicLib::AzimuthalEquidistant class
4
+ *
5
+ * Copyright (c) Charles Karney (2009-2015) <charles@karney.com> and licensed
6
+ * under the MIT/X11 License. For more information, see
7
+ * http://geographiclib.sourceforge.net/
8
+ **********************************************************************/
9
+
10
+ #if !defined(GEOGRAPHICLIB_AZIMUTHALEQUIDISTANT_HPP)
11
+ #define GEOGRAPHICLIB_AZIMUTHALEQUIDISTANT_HPP 1
12
+
13
+ #include <GeographicLib/Geodesic.hpp>
14
+ #include <GeographicLib/Constants.hpp>
15
+
16
+ namespace GeographicLib {
17
+
18
+ /**
19
+ * \brief Azimuthal equidistant projection
20
+ *
21
+ * Azimuthal equidistant projection centered at an arbitrary position on the
22
+ * ellipsoid. For a point in projected space (\e x, \e y), the geodesic
23
+ * distance from the center position is hypot(\e x, \e y) and the azimuth of
24
+ * the geodesic from the center point is atan2(\e x, \e y). The Forward and
25
+ * Reverse methods also return the azimuth \e azi of the geodesic at (\e x,
26
+ * \e y) and reciprocal scale \e rk in the azimuthal direction which,
27
+ * together with the basic properties of the projection, serve to specify
28
+ * completely the local affine transformation between geographic and
29
+ * projected coordinates.
30
+ *
31
+ * The conversions all take place using a Geodesic object (by default
32
+ * Geodesic::WGS84()). For more information on geodesics see \ref geodesic.
33
+ *
34
+ * Example of use:
35
+ * \include example-AzimuthalEquidistant.cpp
36
+ *
37
+ * <a href="GeodesicProj.1.html">GeodesicProj</a> is a command-line utility
38
+ * providing access to the functionality of AzimuthalEquidistant, Gnomonic,
39
+ * and CassiniSoldner.
40
+ **********************************************************************/
41
+
42
+ class GEOGRAPHICLIB_EXPORT AzimuthalEquidistant {
43
+ private:
44
+ typedef Math::real real;
45
+ real eps_;
46
+ Geodesic _earth;
47
+ public:
48
+
49
+ /**
50
+ * Constructor for AzimuthalEquidistant.
51
+ *
52
+ * @param[in] earth the Geodesic object to use for geodesic calculations.
53
+ * By default this uses the WGS84 ellipsoid.
54
+ **********************************************************************/
55
+ explicit AzimuthalEquidistant(const Geodesic& earth = Geodesic::WGS84());
56
+
57
+ /**
58
+ * Forward projection, from geographic to azimuthal equidistant.
59
+ *
60
+ * @param[in] lat0 latitude of center point of projection (degrees).
61
+ * @param[in] lon0 longitude of center point of projection (degrees).
62
+ * @param[in] lat latitude of point (degrees).
63
+ * @param[in] lon longitude of point (degrees).
64
+ * @param[out] x easting of point (meters).
65
+ * @param[out] y northing of point (meters).
66
+ * @param[out] azi azimuth of geodesic at point (degrees).
67
+ * @param[out] rk reciprocal of azimuthal scale at point.
68
+ *
69
+ * \e lat0 and \e lat should be in the range [&minus;90&deg;, 90&deg;].
70
+ * The scale of the projection is 1 in the "radial" direction, \e azi
71
+ * clockwise from true north, and is 1/\e rk in the direction perpendicular
72
+ * to this. A call to Forward followed by a call to Reverse will return
73
+ * the original (\e lat, \e lon) (to within roundoff).
74
+ **********************************************************************/
75
+ void Forward(real lat0, real lon0, real lat, real lon,
76
+ real& x, real& y, real& azi, real& rk) const;
77
+
78
+ /**
79
+ * Reverse projection, from azimuthal equidistant to geographic.
80
+ *
81
+ * @param[in] lat0 latitude of center point of projection (degrees).
82
+ * @param[in] lon0 longitude of center point of projection (degrees).
83
+ * @param[in] x easting of point (meters).
84
+ * @param[in] y northing of point (meters).
85
+ * @param[out] lat latitude of point (degrees).
86
+ * @param[out] lon longitude of point (degrees).
87
+ * @param[out] azi azimuth of geodesic at point (degrees).
88
+ * @param[out] rk reciprocal of azimuthal scale at point.
89
+ *
90
+ * \e lat0 should be in the range [&minus;90&deg;, 90&deg;]. \e lat will
91
+ * be in the range [&minus;90&deg;, 90&deg;] and \e lon will be in the
92
+ * range [&minus;180&deg;, 180&deg;). The scale of the projection is 1 in
93
+ * the "radial" direction, \e azi clockwise from true north, and is 1/\e rk
94
+ * in the direction perpendicular to this. A call to Reverse followed by a
95
+ * call to Forward will return the original (\e x, \e y) (to roundoff) only
96
+ * if the geodesic to (\e x, \e y) is a shortest path.
97
+ **********************************************************************/
98
+ void Reverse(real lat0, real lon0, real x, real y,
99
+ real& lat, real& lon, real& azi, real& rk) const;
100
+
101
+ /**
102
+ * AzimuthalEquidistant::Forward without returning the azimuth and scale.
103
+ **********************************************************************/
104
+ void Forward(real lat0, real lon0, real lat, real lon,
105
+ real& x, real& y) const {
106
+ real azi, rk;
107
+ Forward(lat0, lon0, lat, lon, x, y, azi, rk);
108
+ }
109
+
110
+ /**
111
+ * AzimuthalEquidistant::Reverse without returning the azimuth and scale.
112
+ **********************************************************************/
113
+ void Reverse(real lat0, real lon0, real x, real y,
114
+ real& lat, real& lon) const {
115
+ real azi, rk;
116
+ Reverse(lat0, lon0, x, y, lat, lon, azi, rk);
117
+ }
118
+
119
+ /** \name Inspector functions
120
+ **********************************************************************/
121
+ ///@{
122
+ /**
123
+ * @return \e a the equatorial radius of the ellipsoid (meters). This is
124
+ * the value inherited from the Geodesic object used in the constructor.
125
+ **********************************************************************/
126
+ Math::real MajorRadius() const { return _earth.MajorRadius(); }
127
+
128
+ /**
129
+ * @return \e f the flattening of the ellipsoid. This is the value
130
+ * inherited from the Geodesic object used in the constructor.
131
+ **********************************************************************/
132
+ Math::real Flattening() const { return _earth.Flattening(); }
133
+ ///@}
134
+
135
+ };
136
+
137
+ } // namespace GeographicLib
138
+
139
+ #endif // GEOGRAPHICLIB_AZIMUTHALEQUIDISTANT_HPP
@@ -0,0 +1,204 @@
1
+ /**
2
+ * \file CassiniSoldner.hpp
3
+ * \brief Header for GeographicLib::CassiniSoldner class
4
+ *
5
+ * Copyright (c) Charles Karney (2009-2015) <charles@karney.com> and licensed
6
+ * under the MIT/X11 License. For more information, see
7
+ * http://geographiclib.sourceforge.net/
8
+ **********************************************************************/
9
+
10
+ #if !defined(GEOGRAPHICLIB_CASSINISOLDNER_HPP)
11
+ #define GEOGRAPHICLIB_CASSINISOLDNER_HPP 1
12
+
13
+ #include <GeographicLib/Geodesic.hpp>
14
+ #include <GeographicLib/GeodesicLine.hpp>
15
+ #include <GeographicLib/Constants.hpp>
16
+
17
+ namespace GeographicLib {
18
+
19
+ /**
20
+ * \brief Cassini-Soldner projection
21
+ *
22
+ * Cassini-Soldner projection centered at an arbitrary position, \e lat0, \e
23
+ * lon0, on the ellipsoid. This projection is a transverse cylindrical
24
+ * equidistant projection. The projection from (\e lat, \e lon) to easting
25
+ * and northing (\e x, \e y) is defined by geodesics as follows. Go north
26
+ * along a geodesic a distance \e y from the central point; then turn
27
+ * clockwise 90&deg; and go a distance \e x along a geodesic.
28
+ * (Although the initial heading is north, this changes to south if the pole
29
+ * is crossed.) This procedure uniquely defines the reverse projection. The
30
+ * forward projection is constructed as follows. Find the point (\e lat1, \e
31
+ * lon1) on the meridian closest to (\e lat, \e lon). Here we consider the
32
+ * full meridian so that \e lon1 may be either \e lon0 or \e lon0 +
33
+ * 180&deg;. \e x is the geodesic distance from (\e lat1, \e lon1) to
34
+ * (\e lat, \e lon), appropriately signed according to which side of the
35
+ * central meridian (\e lat, \e lon) lies. \e y is the shortest distance
36
+ * along the meridian from (\e lat0, \e lon0) to (\e lat1, \e lon1), again,
37
+ * appropriately signed according to the initial heading. [Note that, in the
38
+ * case of prolate ellipsoids, the shortest meridional path from (\e lat0, \e
39
+ * lon0) to (\e lat1, \e lon1) may not be the shortest path.] This procedure
40
+ * uniquely defines the forward projection except for a small class of points
41
+ * for which there may be two equally short routes for either leg of the
42
+ * path.
43
+ *
44
+ * Because of the properties of geodesics, the (\e x, \e y) grid is
45
+ * orthogonal. The scale in the easting direction is unity. The scale, \e
46
+ * k, in the northing direction is unity on the central meridian and
47
+ * increases away from the central meridian. The projection routines return
48
+ * \e azi, the true bearing of the easting direction, and \e rk = 1/\e k, the
49
+ * reciprocal of the scale in the northing direction.
50
+ *
51
+ * The conversions all take place using a Geodesic object (by default
52
+ * Geodesic::WGS84()). For more information on geodesics see \ref geodesic.
53
+ * The determination of (\e lat1, \e lon1) in the forward projection is by
54
+ * solving the inverse geodesic problem for (\e lat, \e lon) and its twin
55
+ * obtained by reflection in the meridional plane. The scale is found by
56
+ * determining where two neighboring geodesics intersecting the central
57
+ * meridian at \e lat1 and \e lat1 + \e dlat1 intersect and taking the ratio
58
+ * of the reduced lengths for the two geodesics between that point and,
59
+ * respectively, (\e lat1, \e lon1) and (\e lat, \e lon).
60
+ *
61
+ * Example of use:
62
+ * \include example-CassiniSoldner.cpp
63
+ *
64
+ * <a href="GeodesicProj.1.html">GeodesicProj</a> is a command-line utility
65
+ * providing access to the functionality of AzimuthalEquidistant, Gnomonic,
66
+ * and CassiniSoldner.
67
+ **********************************************************************/
68
+
69
+ class GEOGRAPHICLIB_EXPORT CassiniSoldner {
70
+ private:
71
+ typedef Math::real real;
72
+ Geodesic _earth;
73
+ GeodesicLine _meridian;
74
+ real _sbet0, _cbet0;
75
+ static const unsigned maxit_ = 10;
76
+
77
+ public:
78
+
79
+ /**
80
+ * Constructor for CassiniSoldner.
81
+ *
82
+ * @param[in] earth the Geodesic object to use for geodesic calculations.
83
+ * By default this uses the WGS84 ellipsoid.
84
+ *
85
+ * This constructor makes an "uninitialized" object. Call Reset to set the
86
+ * central latitude and longitude, prior to calling Forward and Reverse.
87
+ **********************************************************************/
88
+ explicit CassiniSoldner(const Geodesic& earth = Geodesic::WGS84());
89
+
90
+ /**
91
+ * Constructor for CassiniSoldner specifying a center point.
92
+ *
93
+ * @param[in] lat0 latitude of center point of projection (degrees).
94
+ * @param[in] lon0 longitude of center point of projection (degrees).
95
+ * @param[in] earth the Geodesic object to use for geodesic calculations.
96
+ * By default this uses the WGS84 ellipsoid.
97
+ *
98
+ * \e lat0 should be in the range [&minus;90&deg;, 90&deg;].
99
+ **********************************************************************/
100
+ CassiniSoldner(real lat0, real lon0,
101
+ const Geodesic& earth = Geodesic::WGS84());
102
+
103
+ /**
104
+ * Set the central point of the projection
105
+ *
106
+ * @param[in] lat0 latitude of center point of projection (degrees).
107
+ * @param[in] lon0 longitude of center point of projection (degrees).
108
+ *
109
+ * \e lat0 should be in the range [&minus;90&deg;, 90&deg;].
110
+ **********************************************************************/
111
+ void Reset(real lat0, real lon0);
112
+
113
+ /**
114
+ * Forward projection, from geographic to Cassini-Soldner.
115
+ *
116
+ * @param[in] lat latitude of point (degrees).
117
+ * @param[in] lon longitude of point (degrees).
118
+ * @param[out] x easting of point (meters).
119
+ * @param[out] y northing of point (meters).
120
+ * @param[out] azi azimuth of easting direction at point (degrees).
121
+ * @param[out] rk reciprocal of azimuthal northing scale at point.
122
+ *
123
+ * \e lat should be in the range [&minus;90&deg;, 90&deg;]. A call to
124
+ * Forward followed by a call to Reverse will return the original (\e lat,
125
+ * \e lon) (to within roundoff). The routine does nothing if the origin
126
+ * has not been set.
127
+ **********************************************************************/
128
+ void Forward(real lat, real lon,
129
+ real& x, real& y, real& azi, real& rk) const;
130
+
131
+ /**
132
+ * Reverse projection, from Cassini-Soldner to geographic.
133
+ *
134
+ * @param[in] x easting of point (meters).
135
+ * @param[in] y northing of point (meters).
136
+ * @param[out] lat latitude of point (degrees).
137
+ * @param[out] lon longitude of point (degrees).
138
+ * @param[out] azi azimuth of easting direction at point (degrees).
139
+ * @param[out] rk reciprocal of azimuthal northing scale at point.
140
+ *
141
+ * A call to Reverse followed by a call to Forward will return the original
142
+ * (\e x, \e y) (to within roundoff), provided that \e x and \e y are
143
+ * sufficiently small not to "wrap around" the earth. The routine does
144
+ * nothing if the origin has not been set.
145
+ **********************************************************************/
146
+ void Reverse(real x, real y,
147
+ real& lat, real& lon, real& azi, real& rk) const;
148
+
149
+ /**
150
+ * CassiniSoldner::Forward without returning the azimuth and scale.
151
+ **********************************************************************/
152
+ void Forward(real lat, real lon,
153
+ real& x, real& y) const {
154
+ real azi, rk;
155
+ Forward(lat, lon, x, y, azi, rk);
156
+ }
157
+
158
+ /**
159
+ * CassiniSoldner::Reverse without returning the azimuth and scale.
160
+ **********************************************************************/
161
+ void Reverse(real x, real y,
162
+ real& lat, real& lon) const {
163
+ real azi, rk;
164
+ Reverse(x, y, lat, lon, azi, rk);
165
+ }
166
+
167
+ /** \name Inspector functions
168
+ **********************************************************************/
169
+ ///@{
170
+ /**
171
+ * @return true if the object has been initialized.
172
+ **********************************************************************/
173
+ bool Init() const { return _meridian.Init(); }
174
+
175
+ /**
176
+ * @return \e lat0 the latitude of origin (degrees).
177
+ **********************************************************************/
178
+ Math::real LatitudeOrigin() const
179
+ { return _meridian.Latitude(); }
180
+
181
+ /**
182
+ * @return \e lon0 the longitude of origin (degrees).
183
+ **********************************************************************/
184
+ Math::real LongitudeOrigin() const
185
+ { return _meridian.Longitude(); }
186
+
187
+ /**
188
+ * @return \e a the equatorial radius of the ellipsoid (meters). This is
189
+ * the value inherited from the Geodesic object used in the constructor.
190
+ **********************************************************************/
191
+ Math::real MajorRadius() const { return _earth.MajorRadius(); }
192
+
193
+ /**
194
+ * @return \e f the flattening of the ellipsoid. This is the value
195
+ * inherited from the Geodesic object used in the constructor.
196
+ **********************************************************************/
197
+ Math::real Flattening() const { return _earth.Flattening(); }
198
+ ///@}
199
+
200
+ };
201
+
202
+ } // namespace GeographicLib
203
+
204
+ #endif // GEOGRAPHICLIB_CASSINISOLDNER_HPP
@@ -0,0 +1,195 @@
1
+ /**
2
+ * \file CircularEngine.hpp
3
+ * \brief Header for GeographicLib::CircularEngine class
4
+ *
5
+ * Copyright (c) Charles Karney (2011-2015) <charles@karney.com> and licensed
6
+ * under the MIT/X11 License. For more information, see
7
+ * http://geographiclib.sourceforge.net/
8
+ **********************************************************************/
9
+
10
+ #if !defined(GEOGRAPHICLIB_CIRCULARENGINE_HPP)
11
+ #define GEOGRAPHICLIB_CIRCULARENGINE_HPP 1
12
+
13
+ #include <vector>
14
+ #include <GeographicLib/Constants.hpp>
15
+ #include <GeographicLib/SphericalEngine.hpp>
16
+
17
+ #if defined(_MSC_VER)
18
+ // Squelch warnings about dll vs vector
19
+ # pragma warning (push)
20
+ # pragma warning (disable: 4251)
21
+ #endif
22
+
23
+ namespace GeographicLib {
24
+
25
+ /**
26
+ * \brief Spherical harmonic sums for a circle
27
+ *
28
+ * The class is a companion to SphericalEngine. If the results of a
29
+ * spherical harmonic sum are needed for several points on a circle of
30
+ * constant latitude \e lat and height \e h, then SphericalEngine::Circle can
31
+ * compute the inner sum, which is independent of longitude \e lon, and
32
+ * produce a CircularEngine object. CircularEngine::operator()() can
33
+ * then be used to perform the outer sum for particular vales of \e lon.
34
+ * This can lead to substantial improvements in computational speed for high
35
+ * degree sum (approximately by a factor of \e N / 2 where \e N is the
36
+ * maximum degree).
37
+ *
38
+ * CircularEngine is tightly linked to the internals of SphericalEngine. For
39
+ * that reason, the constructor for this class is private. Use
40
+ * SphericalHarmonic::Circle, SphericalHarmonic1::Circle, and
41
+ * SphericalHarmonic2::Circle to create instances of this class.
42
+ *
43
+ * CircularEngine stores the coefficients needed to allow the summation over
44
+ * order to be performed in 2 or 6 vectors of length \e M + 1 (depending on
45
+ * whether gradients are to be calculated). For this reason the constructor
46
+ * may throw a std::bad_alloc exception.
47
+ *
48
+ * Example of use:
49
+ * \include example-CircularEngine.cpp
50
+ **********************************************************************/
51
+
52
+ class GEOGRAPHICLIB_EXPORT CircularEngine {
53
+ private:
54
+ typedef Math::real real;
55
+ enum normalization {
56
+ FULL = SphericalEngine::FULL,
57
+ SCHMIDT = SphericalEngine::SCHMIDT,
58
+ };
59
+ int _M;
60
+ bool _gradp;
61
+ unsigned _norm;
62
+ real _a, _r, _u, _t;
63
+ std::vector<real> _wc, _ws, _wrc, _wrs, _wtc, _wts;
64
+ real _q, _uq, _uq2;
65
+
66
+ Math::real Value(bool gradp, real sl, real cl,
67
+ real& gradx, real& grady, real& gradz) const;
68
+
69
+ friend class SphericalEngine;
70
+ CircularEngine(int M, bool gradp, unsigned norm,
71
+ real a, real r, real u, real t)
72
+ : _M(M)
73
+ , _gradp(gradp)
74
+ , _norm(norm)
75
+ , _a(a)
76
+ , _r(r)
77
+ , _u(u)
78
+ , _t(t)
79
+ , _wc(std::vector<real>(_M + 1, 0))
80
+ , _ws(std::vector<real>(_M + 1, 0))
81
+ , _wrc(std::vector<real>(_gradp ? _M + 1 : 0, 0))
82
+ , _wrs(std::vector<real>(_gradp ? _M + 1 : 0, 0))
83
+ , _wtc(std::vector<real>(_gradp ? _M + 1 : 0, 0))
84
+ , _wts(std::vector<real>(_gradp ? _M + 1 : 0, 0))
85
+ {
86
+ _q = _a / _r;
87
+ _uq = _u * _q;
88
+ _uq2 = Math::sq(_uq);
89
+ }
90
+
91
+ void SetCoeff(int m, real wc, real ws)
92
+ { _wc[m] = wc; _ws[m] = ws; }
93
+
94
+ void SetCoeff(int m, real wc, real ws,
95
+ real wrc, real wrs, real wtc, real wts) {
96
+ _wc[m] = wc; _ws[m] = ws;
97
+ if (_gradp) {
98
+ _wrc[m] = wrc; _wrs[m] = wrs;
99
+ _wtc[m] = wtc; _wts[m] = wts;
100
+ }
101
+ }
102
+
103
+ public:
104
+
105
+ /**
106
+ * A default constructor. CircularEngine::operator()() on the resulting
107
+ * object returns zero. The resulting object can be assigned to the result
108
+ * of SphericalHarmonic::Circle.
109
+ **********************************************************************/
110
+ CircularEngine()
111
+ : _M(-1)
112
+ , _gradp(true)
113
+ , _u(0)
114
+ , _t(1)
115
+ {}
116
+
117
+ /**
118
+ * Evaluate the sum for a particular longitude given in terms of its
119
+ * sine and cosine.
120
+ *
121
+ * @param[in] sinlon the sine of the longitude.
122
+ * @param[in] coslon the cosine of the longitude.
123
+ * @return \e V the value of the sum.
124
+ *
125
+ * The arguments must satisfy <i>sinlon</i><sup>2</sup> +
126
+ * <i>coslon</i><sup>2</sup> = 1.
127
+ **********************************************************************/
128
+ Math::real operator()(real sinlon, real coslon) const {
129
+ real dummy;
130
+ return Value(false, sinlon, coslon, dummy, dummy, dummy);
131
+ }
132
+
133
+ /**
134
+ * Evaluate the sum for a particular longitude.
135
+ *
136
+ * @param[in] lon the longitude (degrees).
137
+ * @return \e V the value of the sum.
138
+ **********************************************************************/
139
+ Math::real operator()(real lon) const {
140
+ real sinlon, coslon;
141
+ Math::sincosd(lon, sinlon, coslon);
142
+ return (*this)(sinlon, coslon);
143
+ }
144
+
145
+ /**
146
+ * Evaluate the sum and its gradient for a particular longitude given in
147
+ * terms of its sine and cosine.
148
+ *
149
+ * @param[in] sinlon the sine of the longitude.
150
+ * @param[in] coslon the cosine of the longitude.
151
+ * @param[out] gradx \e x component of the gradient.
152
+ * @param[out] grady \e y component of the gradient.
153
+ * @param[out] gradz \e z component of the gradient.
154
+ * @return \e V the value of the sum.
155
+ *
156
+ * The gradients will only be computed if the CircularEngine object was
157
+ * created with this capability (e.g., via \e gradp = true in
158
+ * SphericalHarmonic::Circle). If not, \e gradx, etc., will not be
159
+ * touched. The arguments must satisfy <i>sinlon</i><sup>2</sup> +
160
+ * <i>coslon</i><sup>2</sup> = 1.
161
+ **********************************************************************/
162
+ Math::real operator()(real sinlon, real coslon,
163
+ real& gradx, real& grady, real& gradz) const {
164
+ return Value(true, sinlon, coslon, gradx, grady, gradz);
165
+ }
166
+
167
+ /**
168
+ * Evaluate the sum and its gradient for a particular longitude.
169
+ *
170
+ * @param[in] lon the longitude (degrees).
171
+ * @param[out] gradx \e x component of the gradient.
172
+ * @param[out] grady \e y component of the gradient.
173
+ * @param[out] gradz \e z component of the gradient.
174
+ * @return \e V the value of the sum.
175
+ *
176
+ * The gradients will only be computed if the CircularEngine object was
177
+ * created with this capability (e.g., via \e gradp = true in
178
+ * SphericalHarmonic::Circle). If not, \e gradx, etc., will not be
179
+ * touched.
180
+ **********************************************************************/
181
+ Math::real operator()(real lon,
182
+ real& gradx, real& grady, real& gradz) const {
183
+ real sinlon, coslon;
184
+ Math::sincosd(lon, sinlon, coslon);
185
+ return (*this)(sinlon, coslon, gradx, grady, gradz);
186
+ }
187
+ };
188
+
189
+ } // namespace GeographicLib
190
+
191
+ #if defined(_MSC_VER)
192
+ # pragma warning (pop)
193
+ #endif
194
+
195
+ #endif // GEOGRAPHICLIB_CIRCULARENGINE_HPP