GeographicLib  2.6
DAuxLatitude.hpp
Go to the documentation of this file.
1 /**
2  * \file DAuxLatitude.hpp
3  * \brief Header for the GeographicLib::DAuxLatitude class
4  *
5  * Copyright (c) Charles Karney (2022-2023) <karney@alum.mit.edu> and licensed
6  * under the MIT/X11 License. For more information, see
7  * https://geographiclib.sourceforge.io/
8  **********************************************************************/
9 
10 #if !defined(GEOGRAPHICLIB_DAUXLATITUDE_HPP)
11 #define GEOGRAPHICLIB_DAUXLATITUDE_HPP 1
12 
14 
15 namespace GeographicLib {
16 
17  /**
18  * \brief Divided differences of auxiliary latitudes.
19  *
20  * This class computed the divided differences of auxiliary latitudes and
21  * some other divided differences needed to support rhumb line calculations.
22  **********************************************************************/
24  private:
25  typedef Math::real real;
26  typedef AuxLatitude base;
27  public:
28  /**
29  * Constructor
30  *
31  * @param[in] a equatorial radius.
32  * @param[in] f flattening of ellipsoid. Setting \e f = 0 gives a sphere.
33  * Negative \e f gives a prolate ellipsoid.
34  * @exception GeographicErr if \e a or (1 &minus; \e f) \e a is not
35  * positive.
36  **********************************************************************/
37  DAuxLatitude(real a, real f) : AuxLatitude(a, f) {}
38  /**
39  * The divided difference of one auxiliary latitude with respect to
40  * another.
41  *
42  * @param[in] auxin an AuxLatitude::aux indicating the type of
43  * auxiliary latitude \e zeta.
44  * @param[in] auxout an AuxLatitude::aux indicating the type of
45  * auxiliary latitude \e eta.
46  * @param[in] zeta1 the first of the input auxiliary latitudeas.
47  * @param[in] zeta2 the second of the input auxiliary latitude.
48  * @return the divided difference (\e eta2 - \e eta1) / (\e zeta2 - \e
49  * zeta1).
50  *
51  * \note This routine uses the series method.
52  *
53  * In the expression for the divided difference above, the angle quantities
54  * should be understood as the conventional measure of angle (either in
55  * radians or in degrees).
56  *
57  * The Fourier coefficients for a specific \e auxin and \e auxout are
58  * computed and saved on the first call; the saved coefficients are used on
59  * subsequent calls. The series method is accurate for abs(\e f) &le;
60  * 1/150.
61  **********************************************************************/
62  Math::real DConvert(int auxin, int auxout,
63  const AuxAngle& zeta1, const AuxAngle& zeta2) const;
64  /**
65  * The divided difference of the parametric latitude with respect to the
66  * geographic latitude.
67  *
68  * @param[in] phi1 the first geographic latitude as an AuxAngle.
69  * @param[in] phi2 the second geographic latitude as an AuxAngle.
70  * @return the divided difference (\e beta2 - \e beta1) / (\e phi2 - \e
71  * phi1), where \e beta is the parametric latitude.
72  *
73  * \note This routine uses the exact formulas and is valid for arbitrary
74  * flattening.
75  **********************************************************************/
76  Math::real DParametric(const AuxAngle& phi1, const AuxAngle& phi2) const;
77  /**
78  * The divided difference of the rectifying latitude with respect to the
79  * geographic latitude.
80  *
81  * @param[in] phi1 the first geographic latitude as an AuxAngle.
82  * @param[in] phi2 the second geographic latitude as an AuxAngle.
83  * @return the divided difference (\e mu2 - \e mu1) / (\e phi2 - \e
84  * phi1), where \e mu is the rectifying latitude.
85  *
86  * \note This routine uses the exact formulas and is valid for arbitrary
87  * flattening.
88  **********************************************************************/
89  Math::real DRectifying(const AuxAngle& phi1, const AuxAngle& phi2) const;
90  /**
91  * The divided difference of the isometric latitude with respect to the
92  * geographic latitude.
93  *
94  * @param[in] phi1 the first geographic latitude as an AuxAngle.
95  * @param[in] phi2 the second geographic latitude as an AuxAngle.
96  * @return the divided difference (\e psi2 - \e psi1) / (\e phi2 - \e
97  * phi1), where \e psi = asinh( tan(\e chi) ) is the isometric latitude
98  * and \e chi is the conformal latitude.
99  *
100  * \note This routine uses the exact formulas and is valid for arbitrary
101  * flattening.
102  **********************************************************************/
103  Math::real DIsometric(const AuxAngle& phi1, const AuxAngle& phi2) const;
104  /**
105  * The divided difference of AuxLatitude::Clenshaw.
106  *
107  * @param[in] sinp if true sum the sine series, else sum the cosine series.
108  * @param[in] Delta either 1 \e or (zeta2 - zeta1) in radians.
109  * @param[in] szeta1 sin(\e zeta1).
110  * @param[in] czeta1 cos(\e zeta1).
111  * @param[in] szeta2 sin(\e zeta2).
112  * @param[in] czeta2 cos(\e zeta2).
113  * @param[in] c the array of coefficients.
114  * @param[in] K the number of coefficients.
115  * @return the divided difference.
116  *
117  * The result is
118  * <pre>
119  * ( AuxLatitude::Clenshaw(sinp, szeta2, czeta2, c, K) -
120  * AuxLatitude::Clenshaw(sinp, szeta1, czeta1, c, K) ) / Delta
121  * </pre>
122  *
123  * \warning \e Delta **must** be either 1 or (\e zeta2 - \e zeta1);
124  * other values will return nonsense.
125  **********************************************************************/
126  static Math::real DClenshaw(bool sinp, real Delta,
127  real szeta1, real czeta1,
128  real szeta2, real czeta2,
129  const real c[], int K);
130  /**
131  * The divided difference of the isometric latitude with respect to the
132  * conformal latitude.
133  *
134  * @param[in] x tan(\e chi1).
135  * @param[in] y tan(\e chi2).
136  * @return the divided difference (\e psi2 - \e psi1) / (\e chi2 - \e
137  * chi1), where \e psi = asinh( tan(\e chi) ).
138  *
139  * \note This parameters for this routine are the \e tangents of conformal
140  * latitude.
141  *
142  * This routine computes Dasinh(x, y) / Datan(x, y).
143  **********************************************************************/
144  static Math::real Dlam(real x, real y) {
145  using std::isnan, std::isinf;
146  return x == y ? base::sc(x) :
147  (isnan(x) || isnan(y) ? std::numeric_limits<real>::quiet_NaN() :
148  (isinf(x) || isinf(y) ? std::numeric_limits<real>::infinity() :
149  Dasinh(x, y) / Datan(x, y)));
150  }
151  // Dp0Dpsi in terms of chi
152  /**
153  * The divided difference of the spherical rhumb area term with respect to
154  * the isometric latitude.
155  *
156  * @param[in] x tan(\e chi1).
157  * @param[in] y tan(\e chi2).
158  * @return the divided difference (p0(\e chi2) - p0(\e chi1)) / (\e psi2 -
159  * \e psi1), where p0(\e chi) = log( sec(\e chi) ) and \e psi = asinh(
160  * tan(\e chi) ).
161  *
162  * \note This parameters for this routine are the \e tangents of conformal
163  * latitude.
164  **********************************************************************/
165  static Math::real Dp0Dpsi(real x, real y) {
166  using std::isnan, std::isinf, std::copysign;
167  return x == y ? base::sn(x) :
168  (isnan(x + y) ? x + y : // N.B. nan for inf-inf
169  (isinf(x) ? copysign(real(1), x) :
170  (isinf(y) ? copysign(real(1), y) :
171  Dasinh(h(x), h(y)) * Dh(x, y) / Dasinh(x, y))));
172  }
173  protected: // so TestAux can access these functions
174  /// \cond SKIP
175  // (sn(y) - sn(x)) / (y - x)
176  static real Dsn(real x, real y);
177  static real Datan(real x, real y);
178  static real Dasinh(real x, real y);
179  // h(tan(x)) = tan(x) * sin(x) / 2
180  static real h(real x) { return x * base::sn(x) / 2; }
181  static real Dh(real x, real y);
182  real Datanhee(real tphi1, real tphi2) const;
183  /// \endcond
184  private:
185  static real Dsin(real x, real y) {
186  using std::sin, std::cos;
187  real d = (x - y) / 2;
188  return cos((x + y) / 2) * (d != 0 ? sin(d) / d : 1);
189  }
190  // (E(x) - E(y)) / (x - y)
191  real DE(const AuxAngle& X, const AuxAngle& Y) const;
192  };
193 
194 } // namespace GeographicLib
195 
196 #endif // GEOGRAPHICLIB_DAUXLATITUDE_HPP
#define GEOGRAPHICLIB_EXPORT
Definition: Constants.hpp:59
An accurate representation of angles.
Definition: AuxAngle.hpp:51
static Math::real Dlam(real x, real y)
DAuxLatitude(real a, real f)
Namespace for GeographicLib.
Definition: Accumulator.cpp:12
GeographicLib::Math::real real
Definition: Geod3Solve.cpp:25
Conversions between auxiliary latitudes.
Definition: AuxLatitude.hpp:75
static Math::real Dp0Dpsi(real x, real y)
Divided differences of auxiliary latitudes.
Header for the GeographicLib::AuxLatitude class.