GeographicLib
2.7
Toggle main menu visibility
Loading...
Searching...
No Matches
AuxAngle.cpp
Go to the documentation of this file.
1
/**
2
* \file AuxAngle.cpp
3
* \brief Implementation for the GeographicLib::AuxAngle class.
4
*
5
* This file is an implementation of the methods described in
6
* - C. F. F. Karney,
7
* <a href="https://doi.org/10.1080/00396265.2023.2217604">
8
* On auxiliary latitudes,</a>
9
* Survey Review 56(395), 165--180 (2024);
10
* preprint
11
* <a href="https://arxiv.org/abs/2212.05818">arXiv:2212.05818</a>.
12
* .
13
* Copyright (c) Charles Karney (2022-2023) <karney@alum.mit.edu> and licensed
14
* under the MIT/X11 License. For more information, see
15
* https://geographiclib.sourceforge.io/
16
**********************************************************************/
17
18
#include <
GeographicLib/AuxAngle.hpp
>
19
20
namespace
GeographicLib
{
21
22
using namespace
std;
23
24
AuxAngle
AuxAngle::NaN
() {
25
return
AuxAngle
(
Math::NaN
(),
Math::NaN
());
26
}
27
28
AuxAngle
AuxAngle::normalized
()
const
{
29
if
( isnan(
tan
() ) ||
30
(fabs(_y) > numeric_limits<real>::max()/2 &&
31
fabs(_x) > numeric_limits<real>::max()/2) )
32
// deal with
33
// (0,0), (inf,inf), (nan,nan), (nan,x), (y,nan), (toobig,toobig)
34
return
NaN
();
35
real r = hypot(_y, _x),
36
y
= _y/r,
x
= _x/r;
37
// deal with r = inf, then one of y,x becomes 1
38
if
(isnan(
y
))
y
= copysign(
real
(1), _y);
39
if
(isnan(
x
))
x
= copysign(
real
(1), _x);
40
return
AuxAngle
(
y
,
x
);
41
}
42
43
AuxAngle
AuxAngle::copyquadrant
(
const
AuxAngle
& p)
const
{
44
return
AuxAngle
(copysign(
y
(), p.
y
()), copysign(
x
(), p.
x
()));
45
}
46
47
AuxAngle
&
AuxAngle::operator+=
(
const
AuxAngle
& p) {
48
// Do nothing if p.tan() == 0 to preserve signs of y() and x()
49
if
(p.
tan
() != 0) {
50
real
x
= _x * p._x - _y * p._y;
51
_y = _y * p._x + _x * p._y;
52
_x =
x
;
53
}
54
return
*
this
;
55
}
56
57
}
// namespace GeographicLib
AuxAngle.hpp
Header for the GeographicLib::AuxAngle class.
real
GeographicLib::Math::real real
Definition
Geod3Solve.cpp:25
GeographicLib::AuxAngle::y
Math::real y() const
Definition
AuxAngle.hpp:74
GeographicLib::AuxAngle::x
Math::real x() const
Definition
AuxAngle.hpp:79
GeographicLib::AuxAngle::normalized
AuxAngle normalized() const
Definition
AuxAngle.cpp:28
GeographicLib::AuxAngle::operator+=
AuxAngle & operator+=(const AuxAngle &p)
Definition
AuxAngle.cpp:47
GeographicLib::AuxAngle::NaN
static AuxAngle NaN()
Definition
AuxAngle.cpp:24
GeographicLib::AuxAngle::tan
Math::real tan() const
Definition
AuxAngle.hpp:117
GeographicLib::AuxAngle::copyquadrant
AuxAngle copyquadrant(const AuxAngle &p) const
Definition
AuxAngle.cpp:43
GeographicLib::AuxAngle::AuxAngle
AuxAngle(real y=0, real x=1)
Definition
AuxAngle.hpp:69
GeographicLib::Math::NaN
static T NaN()
Definition
Math.cpp:301
GeographicLib
Namespace for GeographicLib.
Definition
Accumulator.cpp:12
src
AuxAngle.cpp
Generated by
1.17.0