GeographicLib 2.5
GeographicLib::AuxAngle Class Reference

An accurate representation of angles. More...

#include <GeographicLib/AuxAngle.hpp>

Public Member Functions

 AuxAngle (real y=0, real x=1)
 
Math::real y () const
 
Math::real x () const
 
Math::realy ()
 
Math::realx ()
 
Math::real degrees () const
 
Math::real radians () const
 
Math::real lam () const
 
Math::real lamd () const
 
Math::real tan () const
 
AuxAngle normalized () const
 
void normalize ()
 
AuxAngle copyquadrant (const AuxAngle &p) const
 
AuxAngleoperator+= (const AuxAngle &p)
 

Static Public Member Functions

static AuxAngle degrees (real d)
 
static AuxAngle radians (real r)
 
static AuxAngle lam (real psi)
 
static AuxAngle lamd (real psid)
 
static AuxAngle NaN ()
 

Detailed Description

An accurate representation of angles.

This class is an implementation of the methods described in

An angle is represented be the y and x coordinates of a point in the 2d plane. The two coordinates are proportional to the sine and cosine of the angle. This allows angles close to the cardinal points to be represented accurately. It also saves on unnecessary recomputations of trigonometric functions of the angle. Only angles in [−180°, 180°] can be represented. (A possible extension would be to keep count of the number of turns.)

Example of use:

// Example of using the GeographicLib::AuxAngle class.
#include <iostream>
#include <iomanip>
#include <exception>
int main(int argc, const char* const argv[]) {
try {
typedef GeographicLib::AuxAngle angle;
// Print table of parametric latitudes for f = 0.5
double f = 0.5;
std::cout << std::fixed << std::setprecision(4);
for (int d = 0; d <= 90; d+=10) {
angle phi(angle::degrees(d)), beta(phi);
beta.y() *= (1 - f);
std::cout << d << " " << beta.degrees() << "\n";
}
}
catch (const std::exception& e) {
std::cerr << "Caught exception: " << e.what() << "\n";
return 1;
}
}
Header for the GeographicLib::AuxAngle class.
int main(int argc, const char *const argv[])
Header for GeographicLib::Utility class.
An accurate representation of angles.
Definition AuxAngle.hpp:47

Definition at line 47 of file AuxAngle.hpp.

Constructor & Destructor Documentation

◆ AuxAngle()

GeographicLib::AuxAngle::AuxAngle ( real  y = 0,
real  x = 1 
)
inlineexplicit

The constructor.

Parameters
[in]ythe y coordinate.
[in]xthe x coordinate.
Note
the y coordinate is specified first.
Warning
either x or y can be infinite, but not both.

The defaults (x = 1 and y = 0) are such that

  • no arguments gives an angle of 0;
  • 1 argument specifies the tangent of the angle.

Definition at line 65 of file AuxAngle.hpp.

Member Function Documentation

◆ y() [1/2]

◆ x() [1/2]

◆ y() [2/2]

Math::real & GeographicLib::AuxAngle::y ( )
inline
Returns
a reference to the y component. This allows this component to be altered.

Definition at line 80 of file AuxAngle.hpp.

◆ x() [2/2]

Math::real & GeographicLib::AuxAngle::x ( )
inline
Returns
a reference to the x component. This allows this component to be altered.

Definition at line 85 of file AuxAngle.hpp.

◆ degrees() [1/2]

Math::real GeographicLib::AuxAngle::degrees ( ) const
inline
Returns
the AuxAngle converted to the conventional angle measured in degrees.

Definition at line 224 of file AuxAngle.hpp.

References GeographicLib::Math::atan2d().

Referenced by GeographicLib::AuxLatitude::Convert(), GeographicLib::Rhumb::GenInverse(), and GeographicLib::RhumbLine::GenPosition().

◆ radians() [1/2]

Math::real GeographicLib::AuxAngle::radians ( ) const
inline
Returns
the AuxAngle converted to the conventional angle measured in radians.

Definition at line 228 of file AuxAngle.hpp.

Referenced by GeographicLib::AuxLatitude::Convert(), GeographicLib::DAuxLatitude::DConvert(), GeographicLib::DAuxLatitude::DRectifying(), and GeographicLib::Rhumb::GenInverse().

◆ lam() [1/2]

Math::real GeographicLib::AuxAngle::lam ( ) const
inline
Returns
the lambertian of the AuxAngle.
Note
the lambertian of an angle χ is lam(χ) = asinh(tan(χ)).

Definition at line 232 of file AuxAngle.hpp.

References tan().

Referenced by GeographicLib::Rhumb::GenInverse().

◆ lamd() [1/2]

Math::real GeographicLib::AuxAngle::lamd ( ) const
inline
Returns
the lambertian of the AuxAngle in degrees.
Note
the lambertian of an angle χ is lam(χ) = asinh(tan(χ)).

Definition at line 236 of file AuxAngle.hpp.

References GeographicLib::Math::degree(), and tan().

◆ tan()

◆ normalized()

AuxAngle GeographicLib::AuxAngle::normalized ( ) const
Returns
a new normalized AuxAngle with the point lying on the unit circle and the y and x components are equal to the sine and cosine of the angle.

Definition at line 28 of file AuxAngle.cpp.

References NaN(), tan(), x(), and y().

Referenced by GeographicLib::AuxLatitude::Authalic(), GeographicLib::AuxLatitude::Conformal(), GeographicLib::AuxLatitude::Convert(), GeographicLib::DAuxLatitude::DConvert(), and GeographicLib::AuxLatitude::Rectifying().

◆ normalize()

void GeographicLib::AuxAngle::normalize ( )
inline

Normalize the AuxAngle in place so that the y and x components are equal to the sine and cosine of the angle.

Definition at line 124 of file AuxAngle.hpp.

◆ copyquadrant()

AuxAngle GeographicLib::AuxAngle::copyquadrant ( const AuxAngle p) const

Set the quadrant for the AuxAngle.

Parameters
[in]pthe AuxAngle from which the quadrant information is taken.
Returns
the new AuxAngle in the same quadrant as p.

Definition at line 44 of file AuxAngle.cpp.

References x(), and y().

Referenced by GeographicLib::AuxLatitude::FromAuxiliary().

◆ operator+=()

AuxAngle & GeographicLib::AuxAngle::operator+= ( const AuxAngle p)

Add an AuxAngle.

Parameters
[in]pthe AuxAngle to be added.
Returns
a reference to the new AuxAngle.

The addition is done in place, altering the current AuxAngle.

Warning
Neither *this nor p should have an infinite component. If necessary, invoke AuxAngle::normalize on these angles first.

Definition at line 48 of file AuxAngle.cpp.

References tan(), and x().

◆ degrees() [2/2]

AuxAngle GeographicLib::AuxAngle::degrees ( real  d)
inlinestatic

Construct and return an AuxAngle specied as an angle in degrees.

Parameters
[in]dthe angle measured in degrees.
Returns
the corresponding AuxAngle.

This allows a new AuxAngle to be initialized as an angle in degrees with

Math::real degrees() const
Definition AuxAngle.hpp:224

Definition at line 203 of file AuxAngle.hpp.

References GeographicLib::Math::sincosd(), x(), and y().

◆ radians() [2/2]

AuxAngle GeographicLib::AuxAngle::radians ( real  r)
inlinestatic

Construct and return an AuxAngle specied as an angle in radians.

Parameters
[in]rthe angle measured in radians.
Returns
the corresponding AuxAngle.

This allows a new AuxAngle to be initialized as an angle in radians with

Math::real radians() const
Definition AuxAngle.hpp:228

Definition at line 209 of file AuxAngle.hpp.

◆ lam() [2/2]

AuxAngle GeographicLib::AuxAngle::lam ( real  psi)
inlinestatic

Construct and return an AuxAngle specied by the lambertian of the angle.

Parameters
[in]psithe lambertian of the angle.
Returns
the corresponding AuxAngle.

This allows a new AuxAngle to be initialized given the lambertian with

Math::real lam() const
Definition AuxAngle.hpp:232
Note
this sets the angle χ to gd(ψ) = atan(sinh(ψ)).

Definition at line 214 of file AuxAngle.hpp.

◆ lamd() [2/2]

AuxAngle GeographicLib::AuxAngle::lamd ( real  psid)
inlinestatic

Construct and return an AuxAngle specied by the lambertian of the angle in degrees.

Parameters
[in]psidthe lambertian of the angle in degrees.
Returns
the corresponding AuxAngle.

This allows a new AuxAngle to be initialized given the lambertian with

Math::real lamd() const
Definition AuxAngle.hpp:236
Note
this sets the angle χ to gd(ψ) = atan(sinh(ψ)).

Definition at line 219 of file AuxAngle.hpp.

References GeographicLib::Math::degree().

◆ NaN()

AuxAngle GeographicLib::AuxAngle::NaN ( )
static

The documentation for this class was generated from the following files: