33# pragma warning (disable: 5054)
40 void GeodesicLine::LineInit(
const Geodesic& g,
61 Math::norm(sbet1, cbet1); cbet1 = fmax(tiny_, cbet1);
62 _dn1 = sqrt(1 + g._ep2 *
Math::sq(sbet1));
65 _salp0 = _salp1 * cbet1;
68 _calp0 = hypot(_calp1, _salp1 * sbet1);
78 _ssig1 = sbet1; _somg1 = _salp0 * sbet1;
79 _csig1 = _comg1 = sbet1 != 0 || _calp1 != 0 ? cbet1 * _calp1 : 1;
84 real eps = _k2 / (2 * (1 + sqrt(1 + _k2)) + _k2);
87 _aA1m1 = Geodesic::A1m1f(eps);
88 Geodesic::C1f(eps, _cC1a);
89 _bB11 = Geodesic::SinCosSeries(
true, _ssig1, _csig1, _cC1a, nC1_);
90 real s = sin(_bB11), c = cos(_bB11);
92 _stau1 = _ssig1 * c + _csig1 * s;
93 _ctau1 = _csig1 * c - _ssig1 * s;
99 Geodesic::C1pf(eps, _cC1pa);
101 if (_caps & CAP_C2) {
102 _aA2m1 = Geodesic::A2m1f(eps);
103 Geodesic::C2f(eps, _cC2a);
104 _bB21 = Geodesic::SinCosSeries(
true, _ssig1, _csig1, _cC2a, nC2_);
107 if (_caps & CAP_C3) {
109 _aA3c = -_f * _salp0 * g.A3f(eps);
110 _bB31 = Geodesic::SinCosSeries(
true, _ssig1, _csig1, _cC3a, nC3_-1);
113 if (_caps & CAP_C4) {
116 _aA4 =
Math::sq(_a) * _calp0 * _salp0 * g._e2;
117 _bB41 = Geodesic::SinCosSeries(
false, _ssig1, _csig1, _cC4a, nC4_);
124 real lat1, real lon1, real azi1,
130 LineInit(g, lat1, lon1, azi1, salp1, calp1, caps);
136 unsigned caps,
bool arcmode,
real s13_a13) {
137 LineInit(g, lat1, lon1, azi1, salp1, calp1, caps);
143 real& lat2, real& lon2, real& azi2,
144 real& s12, real& m12,
145 real& M12, real& M21,
147 outmask &= _caps & OUT_MASK;
153 real sig12, ssig12, csig12, B12 = 0, AB1 = 0;
161 tau12 = s12_a12 / (_b * (1 + _aA1m1)),
165 B12 = - Geodesic::SinCosSeries(
true,
166 _stau1 * c + _ctau1 * s,
167 _ctau1 * c - _stau1 * s,
169 sig12 = tau12 - (B12 - _bB11);
170 ssig12 = sin(sig12); csig12 = cos(sig12);
171 if (fabs(_f) > 0.01) {
195 ssig2 = _ssig1 * csig12 + _csig1 * ssig12,
196 csig2 = _csig1 * csig12 - _ssig1 * ssig12;
197 B12 = Geodesic::SinCosSeries(
true, ssig2, csig2, _cC1a, nC1_);
198 real serr = (1 + _aA1m1) * (sig12 + (B12 - _bB11)) - s12_a12 / _b;
199 sig12 = sig12 - serr / sqrt(1 + _k2 *
Math::sq(ssig2));
200 ssig12 = sin(sig12); csig12 = cos(sig12);
205 real ssig2, csig2, sbet2, cbet2, salp2, calp2;
207 ssig2 = _ssig1 * csig12 + _csig1 * ssig12;
208 csig2 = _csig1 * csig12 - _ssig1 * ssig12;
209 real dn2 = sqrt(1 + _k2 *
Math::sq(ssig2));
211 if (arcmode || fabs(_f) > 0.01)
212 B12 = Geodesic::SinCosSeries(
true, ssig2, csig2, _cC1a, nC1_);
213 AB1 = (1 + _aA1m1) * (B12 - _bB11);
216 sbet2 = _calp0 * ssig2;
218 cbet2 = hypot(_salp0, _calp0 * csig2);
221 cbet2 = csig2 = tiny_;
223 salp2 = _salp0; calp2 = _calp0 * csig2;
226 s12 = arcmode ? _b * ((1 + _aA1m1) * sig12 + AB1) : s12_a12;
230 real somg2 = _salp0 * ssig2, comg2 = csig2,
231 E = copysign(real(1), _salp0);
235 - (atan2( ssig2, csig2) - atan2( _ssig1, _csig1))
236 + (atan2(E * somg2, comg2) - atan2(E * _somg1, _comg1)))
237 : atan2(somg2 * _comg1 - comg2 * _somg1,
238 comg2 * _comg1 + somg2 * _somg1);
239 real lam12 = omg12 + _aA3c *
240 ( sig12 + (Geodesic::SinCosSeries(
true, ssig2, csig2, _cC3a, nC3_-1)
256 B22 = Geodesic::SinCosSeries(
true, ssig2, csig2, _cC2a, nC2_),
257 AB2 = (1 + _aA2m1) * (B22 - _bB21),
258 J12 = (_aA1m1 - _aA2m1) * sig12 + (AB1 - AB2);
262 m12 = _b * ((dn2 * (_csig1 * ssig2) - _dn1 * (_ssig1 * csig2))
263 - _csig1 * csig2 * J12);
265 real t = _k2 * (ssig2 - _ssig1) * (ssig2 + _ssig1) / (_dn1 + dn2);
266 M12 = csig12 + (t * ssig2 - csig2 * J12) * _ssig1 / _dn1;
267 M21 = csig12 - (t * _ssig1 - _csig1 * J12) * ssig2 / dn2;
271 if (outmask &
AREA) {
273 B42 = Geodesic::SinCosSeries(
false, ssig2, csig2, _cC4a, nC4_);
275 if (_calp0 == 0 || _salp0 == 0) {
277 salp12 = salp2 * _calp1 - calp2 * _salp1;
278 calp12 = calp2 * _calp1 + salp2 * _salp1;
295 salp12 = _calp0 * _salp0 *
296 (csig12 <= 0 ? _csig1 * (1 - csig12) + ssig12 * _ssig1 :
297 ssig12 * (_csig1 * ssig12 / (1 + csig12) + _ssig1));
300 S12 = _c2 * atan2(salp12, calp12) + _aA4 * (B42 - _bB41);
311 _a13 =
GenPosition(
false, _s13, 0u, t, t, t, t, t, t, t, t);
319 GenPosition(
true, _a13,
DISTANCE, t, t, t, _s13, t, t, t, t);
GeographicLib::Math::real real
Header for GeographicLib::GeodesicLine class.
void GenSetDistance(bool arcmode, real s13_a13)
Math::real GenPosition(bool arcmode, real s12_a12, unsigned outmask, real &lat2, real &lon2, real &azi2, real &s12, real &m12, real &M12, real &M21, real &S12) const
void SetDistance(real s13)
static void sincosd(T x, T &sinx, T &cosx)
static T atan2d(T y, T x)
static void norm(T &x, T &y)
static T AngNormalize(T x)
Namespace for GeographicLib.