GeographicLib 2.1.2
GeographicLib::AuxAngle< T > Class Template Reference

An accurate representation of angles. More...

#include <AuxLatitude.hpp>

Public Types

typedef T real
 

Public Member Functions

 AuxAngle (real y=0, real x=1)
 
real y () const
 
real x () const
 
realy ()
 
realx ()
 
real degrees () const
 
real radians () const
 
real tan () const
 
AuxAngle normalized () const
 
void normalize ()
 
AuxAngle copyquadrant (const AuxAngle &p) const
 
AuxAngleoperator+= (const AuxAngle &p)
 
template<typename T1 >
real AbsError (const AuxAngle< T1 > &p) const
 
template<typename T1 >
real RelError (const AuxAngle< T1 > &p) const
 

Static Public Member Functions

static AuxAngle degrees (real d)
 
static AuxAngle radians (real r)
 
static AuxAngle NaN ()
 

Detailed Description

template<typename T = double>
class GeographicLib::AuxAngle< T >

An accurate representation of angles.

Note
This is just sample code. It is not part of GeographicLib itself.

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. Only angles in [−180°, 180°] can be represented. (A possible extension would be to keep count of the number of turns.)

Template Parameters
Tthe floating-point type to use for real numbers.

Definition at line 55 of file AuxLatitude.hpp.

Member Typedef Documentation

◆ real

template<typename T = double>
typedef T GeographicLib::AuxAngle< T >::real

The floating-point type for real numbers. This just connects to the template parameters for the class.

Definition at line 61 of file AuxLatitude.hpp.

Constructor & Destructor Documentation

◆ AuxAngle()

template<typename T = double>
GeographicLib::AuxAngle< T >::AuxAngle ( real  y = 0,
real  x = 1 
)
inline

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 75 of file AuxLatitude.hpp.

Member Function Documentation

◆ y() [1/2]

template<typename T = double>
real GeographicLib::AuxAngle< T >::y ( ) const
inline
Returns
the y component. This is the sine of the angle if the AuxAngle has been normalized.

Definition at line 80 of file AuxLatitude.hpp.

Referenced by GeographicLib::AuxLatitude< T >::Convert(), GeographicLib::AuxAngle< T >::copyquadrant(), and GeographicLib::AuxLatitude< T >::FromAuxiliary().

◆ x() [1/2]

template<typename T = double>
real GeographicLib::AuxAngle< T >::x ( ) const
inline
Returns
the x component. This is the cosine of the angle if the AuxAngle has been normalized.

Definition at line 85 of file AuxLatitude.hpp.

Referenced by GeographicLib::AuxLatitude< T >::Convert(), GeographicLib::AuxAngle< T >::copyquadrant(), and GeographicLib::AuxLatitude< T >::FromAuxiliary().

◆ y() [2/2]

template<typename T = double>
real & GeographicLib::AuxAngle< T >::y ( )
inline
Returns
a reference to the y component. This allows this component to be altered.

Definition at line 90 of file AuxLatitude.hpp.

◆ x() [2/2]

template<typename T = double>
real & GeographicLib::AuxAngle< T >::x ( )
inline
Returns
a reference to the x component. This allows this component to be altered.

Definition at line 95 of file AuxLatitude.hpp.

◆ degrees() [1/2]

template<typename T = double>
real GeographicLib::AuxAngle< T >::degrees ( ) const
Returns
the AuxAngle converted to the conventional angle measured in degrees.

◆ radians() [1/2]

template<typename T = double>
real GeographicLib::AuxAngle< T >::radians ( ) const
Returns
the AuxAngle converted to the conventional angle measured in radians.

◆ tan()

template<typename T = double>
real GeographicLib::AuxAngle< T >::tan ( ) const
inline
Returns
the tangent of the angle.

Definition at line 109 of file AuxLatitude.hpp.

Referenced by GeographicLib::AuxLatitude< T >::FromAuxiliary(), and GeographicLib::AuxAngle< T >::operator+=().

◆ normalized()

template<typename T >
AuxAngle< T > GeographicLib::AuxAngle< T >::normalized
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 58 of file AuxLatitude.cpp.

Referenced by GeographicLib::AuxLatitude< T >::Convert(), and GeographicLib::AuxAngle< T >::normalize().

◆ normalize()

template<typename T = double>
void GeographicLib::AuxAngle< T >::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 120 of file AuxLatitude.hpp.

References GeographicLib::AuxAngle< T >::normalized().

◆ copyquadrant()

template<typename T >
AuxAngle< T > GeographicLib::AuxAngle< T >::copyquadrant ( const AuxAngle< T > &  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 74 of file AuxLatitude.cpp.

References GeographicLib::AuxAngle< T >::x(), and GeographicLib::AuxAngle< T >::y().

Referenced by GeographicLib::AuxLatitude< T >::FromAuxiliary().

◆ operator+=()

template<typename T >
AuxAngle< T > & GeographicLib::AuxAngle< T >::operator+= ( const AuxAngle< T > &  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 79 of file AuxLatitude.cpp.

References GeographicLib::AuxAngle< T >::tan().

◆ degrees() [2/2]

template<typename T = double>
static AuxAngle GeographicLib::AuxAngle< T >::degrees ( real  d)
static

Convert degrees to an AuxAngle.

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

An accurate representation of angles.
Definition: AuxLatitude.hpp:55

This is the so-called "named constructor" idiom.

◆ radians() [2/2]

template<typename T = double>
static AuxAngle GeographicLib::AuxAngle< T >::radians ( real  r)
static

Convert radians to an AuxAngle.

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

This is the so-called "named constructor" idiom.

◆ NaN()

template<typename T >
AuxAngle< T > GeographicLib::AuxAngle< T >::NaN
static
Returns
a "NaN" AuxAngle.

Definition at line 52 of file AuxLatitude.cpp.

◆ AbsError()

template<typename T = double>
template<typename T1 >
real GeographicLib::AuxAngle< T >::AbsError ( const AuxAngle< T1 > &  p) const

Compute the absolute error in another angle.

Template Parameters
T1the floating-point type of the other angle.
Parameters
[in]pthe other angle
Returns
the absolute error between p and *this considered as angles in radians.

◆ RelError()

template<typename T = double>
template<typename T1 >
real GeographicLib::AuxAngle< T >::RelError ( const AuxAngle< T1 > &  p) const

Compute the relative error in another angle.

Template Parameters
T1the floating-point type of the other angle.
Parameters
[in]pthe other angle
Returns
the relative error between p.tan() and this->tan().

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