NDEVR
API Documentation
Angle< t_type >

Stores an angle in an optimized internal format with support for efficient trigonometric operations. More...

Inheritance diagram for Angle< t_type >:
[legend]

Public Member Functions

constexpr Angle ()
 Default constructor, creates an angle with 0 degrees.
constexpr Angle (AngleType type, fltp04 value)
 Angle Constructor.
constexpr Angle (AngleType type, fltp08 value)
 Angle Constructor.
constexpr Angle (const Angle &angle)
 Default copy constructor.
template<class t_other_type>
constexpr Angle (const Angle< t_other_type > &angle)
 Explicit conversion of an angle from one container type to another.
constexpr Angle (t_type value)
 Constructor.
template<AngleType t_angle_type>
constexpr fltp08 as () const
 Returns a form of this angle as a given type (Radian, Degree, Percent, etc) The template t_type provides the AngleType of the angle to return (Example: radians, degrees, percent).
constexpr fltp08 as (AngleType type) const
 Returns a form of this angle as a given type (Radian, Degree, Percent, etc).
template<bool t_normalized>
constexpr t_type internal () const
 Gets the internal index angle which is the default storage unit for the angle data.
constexpr Angle normalized () const
 returns the normalized angle which lies from 0 to 360 degrees.
constexpr Angle normalizedOffset () const
 returns the normalized angle which lies from -180 to 180 degrees.
constexpr bool operator!= (const Angle &angle) const
 Inequality operator.
Angle operator- () const
 negates the angle
constexpr Angleoperator= (const Angle &angle)
constexpr bool operator== (const Angle &angle) const
 Equality operator.
template<class t_new_type>
constexpr Angle< t_new_type > toTypeAngle () const
 Explicit conversion of an angle from one container type to another.

Static Public Member Functions

template<class t_value_type>
static Angle acos (t_value_type value)
 Computes the principal value of the arc cosine of the given value.
template<class t_value_type>
static Angle asin (t_value_type value)
 Computes the principal value of the arc sine of the given value.
template<class t_value_type>
static Angle atan (t_value_type value)
 Computes the principal value of the arc tangent of the given value.
template<class t_value_type>
static Angle atan2 (t_value_type x, t_value_type y)
 measures the counterclockwise angle between the positive x-axis and the point (x, y)

Static Public Attributes

static constexpr sint04 INDEX_PI = 32768
 Optimized angle constant representing PI; allows integers to store angles to some degree of accuracy.
static constexpr fltp08 INV_INDEX_PI = { 1.0 / Angle<t_type>::INDEX_PI }
 Precomputed inverse of INDEX_PI used for converting internal angles to other representations.

Detailed Description

template<class t_type = fltp08>
class Angle< t_type >

Stores an angle in an optimized internal format with support for efficient trigonometric operations.


Since all angles are from 0-360 degrees it is possible to make certain optimizations that make use of defined overflow that traditional floating point angles would not be able to achieve. In addition space can be saved and expensive sin, cos, tan functions can be precomputed.

See also
AngleDefinitions, Vector, Matrix

Definition at line 82 of file Angle.h.

Constructor & Destructor Documentation

◆ Angle() [1/3]

template<class t_type = fltp08>
Angle< t_type >::Angle ( AngleType type,
fltp04 value )
inlineexplicitconstexpr

Angle Constructor.

Parameters
[in]typeThe type of the angle given (Example: radians, degrees, percent)
[in]valueThe value of the angle in the units specified by type.

Definition at line 113 of file Angle.h.

◆ Angle() [2/3]

template<class t_type = fltp08>
Angle< t_type >::Angle ( AngleType type,
fltp08 value )
inlineexplicitconstexpr

Angle Constructor.

Parameters
[in]typeThe type of the angle given (Example: radians, degrees, percent)
[in]valueThe value of the angle in the units specified by type.

Definition at line 122 of file Angle.h.

◆ Angle() [3/3]

template<class t_type = fltp08>
Angle< t_type >::Angle ( t_type value)
inlineexplicitconstexpr

Constructor.

Parameters
[in]valuethe optimized input where INDEX_PI is 180 degrees

Definition at line 130 of file Angle.h.

Member Function Documentation

◆ acos()

template<class t_type = fltp08>
template<class t_value_type>
Angle Angle< t_type >::acos ( t_value_type value)
inlinestatic

Computes the principal value of the arc cosine of the given value.

Parameters
[in]value- The value to perform arc cos.
Returns
the arc cosine of the given value as an Angle.

Definition at line 266 of file Angle.h.

References Angle(), acos(), and RADIANS.

Referenced by acos(), and AngleDefinitions::AngleBetween().

◆ as() [1/2]

template<class t_type = fltp08>
template<AngleType t_angle_type>
fltp08 Angle< t_type >::as ( ) const
inlinenodiscardconstexpr

Returns a form of this angle as a given type (Radian, Degree, Percent, etc) The template t_type provides the AngleType of the angle to return (Example: radians, degrees, percent).

Parameters
[in]t_is_signedWhether the given type should be signed or not (-180 - 180 vs 0 to 360)
Returns
A fltp08 representing this angle as the given type.

Definition at line 141 of file Angle.h.

References as(), cast(), DEGREES, internal(), INTERNAL_ANGLE, INV_INDEX_PI, IsInvalid(), PERCENT, PI(), and RADIANS.

Referenced by as(), and as().

◆ as() [2/2]

template<class t_type = fltp08>
fltp08 Angle< t_type >::as ( AngleType type) const
inlinenodiscardconstexpr

Returns a form of this angle as a given type (Radian, Degree, Percent, etc).

Parameters
[in]type- The AngleType of the angle to return (Example: radians, degrees, percent).
Returns
A fltp04 representing this angle as the given type.

Definition at line 165 of file Angle.h.

References as(), DEGREES, INTERNAL_ANGLE, PERCENT, RADIANS, and type.

◆ asin()

template<class t_type = fltp08>
template<class t_value_type>
Angle Angle< t_type >::asin ( t_value_type value)
inlinestatic

Computes the principal value of the arc sine of the given value.

Parameters
[in]value- The value to perform arc sine.
Returns
the arc sine of the given value as an Angle.

Definition at line 277 of file Angle.h.

References Angle(), asin(), and RADIANS.

Referenced by asin(), and XRFunctions::ConvertFromQuaternion().

◆ atan()

template<class t_type = fltp08>
template<class t_value_type>
Angle Angle< t_type >::atan ( t_value_type value)
inlinestatic

Computes the principal value of the arc tangent of the given value.

Parameters
[in]value- The value to perform arc tangent.
Returns
the arc tangent of the given value as an Angle.

Definition at line 288 of file Angle.h.

References Angle(), atan(), and RADIANS.

Referenced by atan(), and AngleDefinitions::Inclination().

◆ atan2()

template<class t_type = fltp08>
template<class t_value_type>
Angle Angle< t_type >::atan2 ( t_value_type x,
t_value_type y )
inlinestatic

measures the counterclockwise angle between the positive x-axis and the point (x, y)

Parameters
[in]x- the numerator or x value of atan
[in]y- the denomenator or y value of atan
Returns
the arc tangent of the given value as an Angle.

Definition at line 300 of file Angle.h.

References Angle(), atan2(), and RADIANS.

Referenced by atan2(), XRFunctions::ConvertFromQuaternion(), AngleDefinitions::Heading(), and AngleDefinitions::Inclination().

◆ internal()

template<class t_type = fltp08>
template<bool t_normalized>
t_type Angle< t_type >::internal ( ) const
inlinenodiscardconstexpr

Gets the internal index angle which is the default storage unit for the angle data.

Returns
The internal index angle, or the angle represented by 0 - Constant<t_type>::Max representing 0 to 2 PI radians

Definition at line 183 of file Angle.h.

References Angle().

Referenced by Angle(), as(), normalized(), operator!=(), operator==(), LineEditResourceSetter< Angle< fltp08 >, ObjectInfo< Angle< fltp08 > >::Number >::ValueToFloat(), and LineEditResourceSetter< Angle< sint04 >, ObjectInfo< Angle< sint04 > >::Number >::ValueToFloat().

◆ operator!=()

template<class t_type = fltp08>
bool Angle< t_type >::operator!= ( const Angle< t_type > & angle) const
inlineconstexpr

Inequality operator.

Parameters
[in]angleThe value to check inequality against.
Returns
true if the left and right are not considered equivalent.

Definition at line 245 of file Angle.h.

References Angle(), and internal().

◆ operator-()

template<class t_type = fltp08>
Angle Angle< t_type >::operator- ( ) const
inline

negates the angle

Returns
The result of the operation.

Definition at line 254 of file Angle.h.

References Angle().

◆ operator=()

template<class t_type = fltp08>
Angle & Angle< t_type >::operator= ( const Angle< t_type > & angle)
inlineconstexpr
Parameters
[in]angle- The value to assign.
Returns
A shallow copy of this object.

Definition at line 224 of file Angle.h.

References Angle().

◆ operator==()

template<class t_type = fltp08>
bool Angle< t_type >::operator== ( const Angle< t_type > & angle) const
inlineconstexpr

Equality operator.

Parameters
[in]angle- The value to check comparison.
Returns
true if the left and right are considered equivalent.

Definition at line 235 of file Angle.h.

References Angle(), and internal().


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