MIRA
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
AngleBase< T, UnitTag, Derived > Class Template Reference

Base class template for derived Angle implementations. More...

#include <math/Angle.h>

Inheritance diagram for AngleBase< T, UnitTag, Derived >:
Inheritance graph
[legend]

Public Member Functions

template<typename Reflector >
void reflect (Reflector &r)
 
void setValue (const T &value)
 Set the angle value. The input value is mapped into the angle interval. More...
 
const T & value () const
 Returns the raw angle value given in the native unit of the angle class. More...
 
 operator T () const
 Conversion function to native type (same as value() ) More...
 
void setSerializedValue (const T &value)
 Sets the value in the unit that is used for serialization. More...
 
serializedValue () const
 Returns the value in the unit that is used for serialization. More...
 
deg () const
 Returns the value of the angle in degrees. More...
 
rad () const
 Returns the value of the angle in radian. More...
 
Derived operator- () const
 Unary minus operator. More...
 
template<typename OtherUnitTag , typename OtherDerived >
Derived operator+= (const AngleBase< T, OtherUnitTag, OtherDerived > &a)
 Add other angle to this angle. More...
 
Derived & operator+= (const T &a)
 Add float value to this angle. More...
 
template<typename OtherUnitTag , typename OtherDerived >
Derived operator-= (const AngleBase< T, OtherUnitTag, OtherDerived > &a)
 Subtract other angle from this angle. More...
 
Derived & operator-= (const T &a)
 Subtract float value from this angle. More...
 
Derived & operator*= (const T &s)
 Multiply this angle with scalar. More...
 
Derived & operator/= (const T &s)
 Divide this angle by scalar. More...
 
smallestDifferenceValue (const Derived &other) const
 Returns the signed difference angle between this angle and the specified other angle that has the smallest absolute value. More...
 
bool isInInterval (const Derived &min, const Derived &max) const
 Returns true, if the angle is in the given interval [min,max]. More...
 

Static Public Member Functions

static T upper ()
 Returns the upper limit of the defined angle interval. More...
 
static const char * unit ()
 Returns the unit of this angle representation as string, e.g. More...
 

Protected Member Functions

 AngleBase (T value, int)
 
 AngleBase ()
 
 AngleBase (T value)
 
 AngleBase (const AngleBase &other)
 
template<typename OtherT , typename OtherUnitTag , typename OtherDerived >
 AngleBase (const AngleBase< OtherT, OtherUnitTag, OtherDerived > &other)
 
template<typename OtherUnitTag , typename OtherDerived >
void operator= (const AngleBase< T, OtherUnitTag, OtherDerived > &other)
 
void operator= (const T &other)
 

Protected Attributes

mValue
 the actual value More...
 

Friends

template<typename OtherUnitTag , typename OtherDerived >
Derived operator+ (const Derived &a, const AngleBase< T, OtherUnitTag, OtherDerived > &b)
 Add two angles. More...
 
Derived operator+ (const AngleBase &a, const T &b)
 Add two angles. More...
 
Derived operator+ (const T &a, const AngleBase &b)
 Add two angles. More...
 
template<typename OtherUnitTag , typename OtherDerived >
Derived operator- (const Derived &a, const AngleBase< T, OtherUnitTag, OtherDerived > &b)
 Subtract two angles. More...
 
Derived operator- (const AngleBase &a, const T &b)
 Subtract two angles. More...
 
Derived operator- (const T &a, const AngleBase &b)
 Subtract two angles. More...
 
Derived operator* (const Derived &a, const T &b)
 Multiply with scalar. More...
 
Derived operator* (const T &a, const Derived &b)
 Multiply with scalar. More...
 
Derived operator/ (const Derived &a, const T &b)
 Divide by scalar. More...
 
bool operator< (const AngleBase &a, const AngleBase &b)
 
bool operator<= (const AngleBase &a, const AngleBase &b)
 
bool operator> (const AngleBase &a, const AngleBase &b)
 
bool operator>= (const AngleBase &a, const AngleBase &b)
 
bool operator== (const AngleBase &a, const AngleBase &b)
 
bool operator!= (const AngleBase &a, const AngleBase &b)
 
std::ostream & operator<< (std::ostream &o, const AngleBase &v)
 stream operator More...
 

Detailed Description

template<typename T, typename UnitTag, typename Derived>
class mira::AngleBase< T, UnitTag, Derived >

Base class template for derived Angle implementations.

Contains major parts of the implementation of the angle classes. Uses curiously recurring template pattern (CRTP) for static polymorphism.

Constructor & Destructor Documentation

◆ AngleBase() [1/5]

AngleBase ( value,
int   
)
inlineprotected

◆ AngleBase() [2/5]

AngleBase ( )
inlineprotected

◆ AngleBase() [3/5]

AngleBase ( value)
inlineexplicitprotected

◆ AngleBase() [4/5]

AngleBase ( const AngleBase< T, UnitTag, Derived > &  other)
inlineprotected

◆ AngleBase() [5/5]

AngleBase ( const AngleBase< OtherT, OtherUnitTag, OtherDerived > &  other)
inlineexplicitprotected

Member Function Documentation

◆ operator=() [1/2]

void operator= ( const AngleBase< T, OtherUnitTag, OtherDerived > &  other)
inlineprotected

◆ operator=() [2/2]

void operator= ( const T &  other)
inlineprotected

◆ reflect()

void reflect ( Reflector &  r)
inline

◆ upper()

static T upper ( )
inlinestatic

Returns the upper limit of the defined angle interval.

Note, that the upper limit does not belong to the interval itself, hence the interval is [lower,upper) .

◆ setValue()

void setValue ( const T &  value)
inline

Set the angle value. The input value is mapped into the angle interval.

◆ value()

const T& value ( ) const
inline

Returns the raw angle value given in the native unit of the angle class.

◆ operator T()

operator T ( ) const
inlineexplicit

Conversion function to native type (same as value() )

Implicit conversion is intentionally disabled, in order to prevent potentially erroneous usage like

Angle a = 2;
T f = 5;
T r = a * f; // r is (T)Angle(2*5), which is NOT 2*5

◆ setSerializedValue()

void setSerializedValue ( const T &  value)
inline

Sets the value in the unit that is used for serialization.

The Angle and SignedAngle classes use radians for storing the value internal and degrees for serializing the value to simplify the usage for the human user. For the other classes Degree, SignedDegree, Radian and SignedRadian setValue() and setSerializedValue() are doing the same.

◆ serializedValue()

T serializedValue ( ) const
inline

Returns the value in the unit that is used for serialization.

The Angle and SignedAngle classes use radians for storing the value internal and degrees for serializing the value to simplify the usage for the human user. For the other classes Degree, SignedDegree, Radian and SignedRadian value() and serializedValue() yield the same result.

◆ deg()

T deg ( ) const
inline

Returns the value of the angle in degrees.

◆ rad()

T rad ( ) const
inline

Returns the value of the angle in radian.

◆ operator-()

Derived operator- ( ) const
inline

Unary minus operator.

◆ operator+=() [1/2]

Derived operator+= ( const AngleBase< T, OtherUnitTag, OtherDerived > &  a)
inline

Add other angle to this angle.

◆ operator+=() [2/2]

Derived& operator+= ( const T &  a)
inline

Add float value to this angle.

◆ operator-=() [1/2]

Derived operator-= ( const AngleBase< T, OtherUnitTag, OtherDerived > &  a)
inline

Subtract other angle from this angle.

◆ operator-=() [2/2]

Derived& operator-= ( const T &  a)
inline

Subtract float value from this angle.

◆ operator*=()

Derived& operator*= ( const T &  s)
inline

Multiply this angle with scalar.

◆ operator/=()

Derived& operator/= ( const T &  s)
inline

Divide this angle by scalar.

◆ smallestDifferenceValue()

T smallestDifferenceValue ( const Derived &  other) const
inline

Returns the signed difference angle between this angle and the specified other angle that has the smallest absolute value.

This method is similar to smallestDifference() but returns a floating point value instead of a signed angle class object.

◆ isInInterval()

bool isInInterval ( const Derived &  min,
const Derived &  max 
) const
inline

Returns true, if the angle is in the given interval [min,max].

If max<min, both values will be swapped.

◆ unit()

static const char* unit ( )
inlinestatic

Returns the unit of this angle representation as string, e.g.

"rad" or "deg"

Friends And Related Function Documentation

◆ operator+ [1/3]

Derived operator+ ( const Derived &  a,
const AngleBase< T, OtherUnitTag, OtherDerived > &  b 
)
friend

Add two angles.

◆ operator+ [2/3]

Derived operator+ ( const AngleBase< T, UnitTag, Derived > &  a,
const T &  b 
)
friend

Add two angles.

◆ operator+ [3/3]

Derived operator+ ( const T &  a,
const AngleBase< T, UnitTag, Derived > &  b 
)
friend

Add two angles.

◆ operator- [1/3]

Derived operator- ( const Derived &  a,
const AngleBase< T, OtherUnitTag, OtherDerived > &  b 
)
friend

Subtract two angles.

◆ operator- [2/3]

Derived operator- ( const AngleBase< T, UnitTag, Derived > &  a,
const T &  b 
)
friend

Subtract two angles.

◆ operator- [3/3]

Derived operator- ( const T &  a,
const AngleBase< T, UnitTag, Derived > &  b 
)
friend

Subtract two angles.

◆ operator* [1/2]

Derived operator* ( const Derived &  a,
const T &  b 
)
friend

Multiply with scalar.

◆ operator* [2/2]

Derived operator* ( const T &  a,
const Derived &  b 
)
friend

Multiply with scalar.

◆ operator/

Derived operator/ ( const Derived &  a,
const T &  b 
)
friend

Divide by scalar.

◆ operator<

bool operator< ( const AngleBase< T, UnitTag, Derived > &  a,
const AngleBase< T, UnitTag, Derived > &  b 
)
friend

◆ operator<=

bool operator<= ( const AngleBase< T, UnitTag, Derived > &  a,
const AngleBase< T, UnitTag, Derived > &  b 
)
friend

◆ operator>

bool operator> ( const AngleBase< T, UnitTag, Derived > &  a,
const AngleBase< T, UnitTag, Derived > &  b 
)
friend

◆ operator>=

bool operator>= ( const AngleBase< T, UnitTag, Derived > &  a,
const AngleBase< T, UnitTag, Derived > &  b 
)
friend

◆ operator==

bool operator== ( const AngleBase< T, UnitTag, Derived > &  a,
const AngleBase< T, UnitTag, Derived > &  b 
)
friend

◆ operator!=

bool operator!= ( const AngleBase< T, UnitTag, Derived > &  a,
const AngleBase< T, UnitTag, Derived > &  b 
)
friend

◆ operator<<

std::ostream& operator<< ( std::ostream &  o,
const AngleBase< T, UnitTag, Derived > &  v 
)
friend

stream operator

Member Data Documentation

◆ mValue

T mValue
protected

the actual value


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