GeographicLib  1.49
JacobiConformal.hpp
Go to the documentation of this file.
1 /**
2  * \file JacobiConformal.hpp
3  * \brief Header for GeographicLib::JacobiConformal class
4  *
5  * <b>NOTE:</b> This is just sample code. It is not part of GeographicLib
6  * itself.
7  *
8  * Copyright (c) Charles Karney (2014-2015) <charles@karney.com> and licensed
9  * under the MIT/X11 License. For more information, see
10  * https://geographiclib.sourceforge.io/
11  **********************************************************************/
12 
14 
15 namespace GeographicLib {
16  /**
17  * \brief Jacobi's conformal projection of a triaxial ellipsoid
18  *
19  * <b>NOTE:</b> This is just sample code. It is not part of GeographicLib
20  * itself.
21  *
22  * This is a conformal projection of the ellipsoid to a plane in which
23  * the grid lines are straight; see Jacobi,
24  * <a href="https://books.google.com/books?id=ryEOAAAAQAAJ&pg=PA212">
25  * Vorlesungen &uuml;ber Dynamik, &sect;28</a>. The constructor takes the
26  * semi-axes of the ellipsoid (which must be in order). Member functions map
27  * the ellipsoidal coordinates &omega; and &beta; separately to \e x and \e
28  * y. Jacobi's coordinates have been multiplied by
29  * (<i>a</i><sup>2</sup>&minus;<i>c</i><sup>2</sup>)<sup>1/2</sup> /
30  * (2<i>b</i>) so that the customary results are returned in the cases of
31  * a sphere or an ellipsoid of revolution.
32  *
33  * The ellipsoid is oriented so that the large principal ellipse, \f$Z=0\f$,
34  * is the equator, \f$\beta=0\f$, while the small principal ellipse,
35  * \f$Y=0\f$, is the prime meridian, \f$\omega=0\f$. The four umbilic
36  * points, \f$\left|\omega\right| = \left|\beta\right| = \frac12\pi\f$, lie
37  * on middle principal ellipse in the plane \f$X=0\f$.
38  *
39  * For more information on this projection, see \ref jacobi.
40  **********************************************************************/
42  typedef Math::real real;
43  real _a, _b, _c, _ab2, _bc2, _ac2;
44  EllipticFunction _ex, _ey;
45  static void norm(real& x, real& y)
46  { real z = Math::hypot(x, y); x /= z; y /= z; }
47  public:
48  /**
49  * Constructor for a trixial ellipsoid with semi-axes.
50  *
51  * @param[in] a the largest semi-axis.
52  * @param[in] b the middle semi-axis.
53  * @param[in] c the smallest semi-axis.
54  *
55  * The semi-axes must satisfy \e a &ge; \e b &ge; \e c > 0 and \e a >
56  * \e c. This form of the constructor cannot be used to specify a
57  * sphere (use the next constructor).
58  **********************************************************************/
59  JacobiConformal(real a, real b, real c)
60  : _a(a), _b(b), _c(c)
61  , _ab2((_a - _b) * (_a + _b))
62  , _bc2((_b - _c) * (_b + _c))
63  , _ac2((_a - _c) * (_a + _c))
64  , _ex(_ab2 / _ac2 * Math::sq(_c / _b), -_ab2 / Math::sq(_b),
65  _bc2 / _ac2 * Math::sq(_a / _b), Math::sq(_a / _b))
66  , _ey(_bc2 / _ac2 * Math::sq(_a / _b), +_bc2 / Math::sq(_b),
67  _ab2 / _ac2 * Math::sq(_c / _b), Math::sq(_c / _b))
68  {
69  if (!(Math::isfinite(_a) && _a >= _b && _b >= _c && _c > 0))
70  throw GeographicErr("JacobiConformal: axes are not in order");
71  if (!(_a > _c))
72  throw GeographicErr
73  ("JacobiConformal: use alternate constructor for sphere");
74  }
75  /**
76  * Alternate constructor for a triaxial ellipsoid.
77  *
78  * @param[in] a the largest semi-axis.
79  * @param[in] b the middle semi-axis.
80  * @param[in] c the smallest semi-axis.
81  * @param[in] ab the relative magnitude of \e a &minus; \e b.
82  * @param[in] bc the relative magnitude of \e b &minus; \e c.
83  *
84  * This form can be used to specify a sphere. The semi-axes must
85  * satisfy \e a &ge; \e b &ge; c > 0. The ratio \e ab : \e bc must equal
86  * (<i>a</i>&minus;<i>b</i>) : (<i>b</i>&minus;<i>c</i>) with \e ab
87  * &ge; 0, \e bc &ge; 0, and \e ab + \e bc > 0.
88  **********************************************************************/
89  JacobiConformal(real a, real b, real c, real ab, real bc)
90  : _a(a), _b(b), _c(c)
91  , _ab2(ab * (_a + _b))
92  , _bc2(bc * (_b + _c))
93  , _ac2(_ab2 + _bc2)
94  , _ex(_ab2 / _ac2 * Math::sq(_c / _b),
95  -(_a - _b) * (_a + _b) / Math::sq(_b),
96  _bc2 / _ac2 * Math::sq(_a / _b), Math::sq(_a / _b))
97  , _ey(_bc2 / _ac2 * Math::sq(_a / _b),
98  +(_b - _c) * (_b + _c) / Math::sq(_b),
99  _ab2 / _ac2 * Math::sq(_c / _b), Math::sq(_c / _b))
100  {
101  if (!(Math::isfinite(_a) && _a >= _b && _b >= _c && _c > 0 &&
102  ab >= 0 && bc >= 0))
103  throw GeographicErr("JacobiConformal: axes are not in order");
104  if (!(ab + bc > 0 && Math::isfinite(_ac2)))
105  throw GeographicErr("JacobiConformal: ab + bc must be positive");
106  }
107  /**
108  * @return the quadrant length in the \e x direction.
109  **********************************************************************/
110  Math::real x() const { return Math::sq(_a / _b) * _ex.Pi(); }
111  /**
112  * The \e x projection.
113  *
114  * @param[in] somg sin(&omega;).
115  * @param[in] comg cos(&omega;).
116  * @return \e x.
117  **********************************************************************/
118  Math::real x(real somg, real comg) const {
119  real somg1 = _b * somg, comg1 = _a * comg; norm(somg1, comg1);
120  return Math::sq(_a / _b)
121  * _ex.Pi(somg1, comg1, _ex.Delta(somg1, comg1));
122  }
123  /**
124  * The \e x projection.
125  *
126  * @param[in] omg &omega; (in degrees).
127  * @return \e x (in degrees).
128  *
129  * &omega; must be in (&minus;180&deg;, 180&deg;].
130  **********************************************************************/
131  Math::real x(real omg) const {
132  real somg, comg;
133  Math::sincosd(omg, somg, comg);
134  return x(somg, comg) / Math::degree();
135  }
136  /**
137  * @return the quadrant length in the \e y direction.
138  **********************************************************************/
139  Math::real y() const { return Math::sq(_c / _b) * _ey.Pi(); }
140  /**
141  * The \e y projection.
142  *
143  * @param[in] sbet sin(&beta;).
144  * @param[in] cbet cos(&beta;).
145  * @return \e y.
146  **********************************************************************/
147  Math::real y(real sbet, real cbet) const {
148  real sbet1 = _b * sbet, cbet1 = _c * cbet; norm(sbet1, cbet1);
149  return Math::sq(_c / _b)
150  * _ey.Pi(sbet1, cbet1, _ey.Delta(sbet1, cbet1));
151  }
152  /**
153  * The \e y projection.
154  *
155  * @param[in] bet &beta; (in degrees).
156  * @return \e y (in degrees).
157  *
158  * &beta; must be in (&minus;180&deg;, 180&deg;].
159  **********************************************************************/
160  Math::real y(real bet) const {
161  real sbet, cbet;
162  Math::sincosd(bet, sbet, cbet);
163  return y(sbet, cbet) / Math::degree();
164  }
165  };
166 
167 } // namespace GeographicLib
GeographicLib::EllipticFunction::Delta
Math::real Delta(real sn, real cn) const
Definition: EllipticFunction.hpp:584
GeographicLib::JacobiConformal::x
Math::real x(real omg) const
Definition: JacobiConformal.hpp:131
GeographicLib::JacobiConformal::x
Math::real x() const
Definition: JacobiConformal.hpp:110
GeographicLib::JacobiConformal::JacobiConformal
JacobiConformal(real a, real b, real c)
Definition: JacobiConformal.hpp:59
GeographicLib
Namespace for GeographicLib.
Definition: Accumulator.cpp:12
EllipticFunction.hpp
Header for GeographicLib::EllipticFunction class.
GeographicLib::Math::isfinite
static bool isfinite(T x)
Definition: Math.hpp:806
GeographicLib::Math::sincosd
static void sincosd(T x, T &sinx, T &cosx)
Definition: Math.hpp:558
GeographicLib::EllipticFunction
Elliptic integrals and functions.
Definition: EllipticFunction.hpp:62
GeographicLib::JacobiConformal::y
Math::real y() const
Definition: JacobiConformal.hpp:139
GeographicLib::GeographicErr
Exception handling for GeographicLib.
Definition: Constants.hpp:389
GeographicLib::Math::real
double real
Definition: Math.hpp:129
GeographicLib::Math
Mathematical functions needed by GeographicLib.
Definition: Math.hpp:102
GeographicLib::Math::degree
static T degree()
Definition: Math.hpp:216
GeographicLib::JacobiConformal::y
Math::real y(real sbet, real cbet) const
Definition: JacobiConformal.hpp:147
GeographicLib::JacobiConformal::JacobiConformal
JacobiConformal(real a, real b, real c, real ab, real bc)
Definition: JacobiConformal.hpp:89
GeographicLib::JacobiConformal::x
Math::real x(real somg, real comg) const
Definition: JacobiConformal.hpp:118
GeographicLib::JacobiConformal::y
Math::real y(real bet) const
Definition: JacobiConformal.hpp:160
GeographicLib::EllipticFunction::Pi
Math::real Pi() const
Definition: EllipticFunction.hpp:237
GeographicLib::JacobiConformal
Jacobi's conformal projection of a triaxial ellipsoid.
Definition: JacobiConformal.hpp:41
GeographicLib::Math::sq
static T sq(T x)
Definition: Math.hpp:232
GeographicLib::Math::hypot
static T hypot(T x, T y)
Definition: Math.hpp:243