GeographicLib 2.3
AuxAngle.cpp
Go to the documentation of this file.
1/**
2 * \file AuxAngle.cpp
3 * \brief Implementation for the GeographicLib::AuxAngle class.
4 *
5 * \note This is just sample code. It is not part of GeographicLib itself.
6 *
7 * This file is an implementation of the methods described in
8 * - C. F. F. Karney,
9 * <a href="https://doi.org/10.1080/00396265.2023.2217604">
10 * On auxiliary latitudes,</a>
11 * Survey Review (2023);
12 * preprint
13 * <a href="https://arxiv.org/abs/2212.05818">arXiv:2212.05818</a>.
14 * .
15 * Copyright (c) Charles Karney (2022-2023) <karney@alum.mit.edu> and licensed
16 * under the MIT/X11 License. For more information, see
17 * https://geographiclib.sourceforge.io/
18 **********************************************************************/
19
21
22namespace GeographicLib {
23
24 using namespace std;
25
27 return AuxAngle(numeric_limits<real>::quiet_NaN(),
28 numeric_limits<real>::quiet_NaN());
29 }
30
32 using std::isnan; // Needed for Centos 7, ubuntu 14
33 if ( isnan( tan() ) ||
34 (fabs(_y) > numeric_limits<real>::max()/2 &&
35 fabs(_x) > numeric_limits<real>::max()/2) )
36 // deal with
37 // (0,0), (inf,inf), (nan,nan), (nan,x), (y,nan), (toobig,toobig)
38 return NaN();
39 real r = hypot(_y, _x),
40 y = _y/r, x = _x/r;
41 // deal with r = inf, then one of y,x becomes 1
42 if (isnan(y)) y = copysign(real(1), _y);
43 if (isnan(x)) x = copysign(real(1), _x);
44 return AuxAngle(y, x);
45 }
46
48 return AuxAngle(copysign(y(), p.y()), copysign(x(), p.x()));
49 }
50
52 // Do nothing if p.tan() == 0 to preserve signs of y() and x()
53 if (p.tan() != 0) {
54 real x = _x * p._x - _y * p._y;
55 _y = _y * p._x + _x * p._y;
56 _x = x;
57 }
58 return *this;
59 }
60
61} // namespace GeographicLib
Header for the GeographicLib::AuxAngle class.
An accurate representation of angles.
Definition: AuxAngle.hpp:47
Math::real y() const
Definition: AuxAngle.hpp:70
Math::real x() const
Definition: AuxAngle.hpp:75
AuxAngle normalized() const
Definition: AuxAngle.cpp:31
AuxAngle & operator+=(const AuxAngle &p)
Definition: AuxAngle.cpp:51
static AuxAngle NaN()
Definition: AuxAngle.cpp:26
Math::real tan() const
Definition: AuxAngle.hpp:113
AuxAngle copyquadrant(const AuxAngle &p) const
Definition: AuxAngle.cpp:47
AuxAngle(real y=0, real x=1)
Definition: AuxAngle.hpp:65
Namespace for GeographicLib.
Definition: Accumulator.cpp:12