BALL::TAngle< T > Class Template Reference

#include <BALL/MATHS/angle.h>

List of all members.

Public Types

Enums
enum  Range { RANGE__UNLIMITED = 0, RANGE__UNSIGNED = 1, RANGE__SIGNED = 2 }

Public Member Functions

Constructors and Destructors
 TAngle ()
 TAngle (const TAngle &angle)
 TAngle (const T &new_value, bool radian=true)
virtual ~TAngle ()
virtual void clear ()
Assignment
void swap (TAngle &angle)
void set (const T &new_value, bool radian=true)
void set (const TAngle &angle)
TAngleoperator= (const TAngle &angle)
TAngleoperator= (const T &new_value)
void get (TAngle &angle) const
void get (T &val, bool radian=true) const
Predicates
bool operator== (const TAngle &angle) const
bool operator!= (const TAngle &angle) const
bool operator< (const TAngle &angle) const
bool operator< (const T &val) const
bool operator<= (const TAngle &angle) const
bool operator>= (const TAngle &angle) const
bool operator> (const TAngle &angle) const
bool isEquivalent (TAngle angle) const
Debugging and Diagnostics
bool isValid () const
void dump (std::ostream &s=std::cout, Size depth=0) const

Public Attributes

Attributes
value

Accessors

 operator T () const
toRadian () const
toDegree () const
void normalize (Range range)
void negate ()
TAngle operator+ () const
TAngle operator- () const
TAngleoperator+= (const TAngle &angle)
TAngleoperator+= (const T &val)
TAngle operator+ (const TAngle &angle)
TAngleoperator-= (const TAngle &angle)
TAngleoperator-= (const T &val)
TAngle operator- (const TAngle &angle)
TAngleoperator*= (const TAngle &angle)
TAngleoperator*= (const T &val)
TAngleoperator/= (const TAngle &angle) throw (Exception::DivisionByZero)
TAngleoperator/= (const T &val) throw (Exception::DivisionByZero)
TAngle operator/ (const TAngle &val) throw (Exception::DivisionByZero)
static T toRadian (const T &degree)
static T toDegree (const T &radian)

Detailed Description

template<typename T>
class BALL::TAngle< T >

Generic Angle Class. Use this class to describe angles. The TAngle class permits the conversion from degree to radians and is the return type of all functions used to calculate angles.


Member Enumeration Documentation

template<typename T>
enum BALL::TAngle::Range

form of the angle range: RANGE__UNLIMITED = 0 no limitations RANGE__UNSIGNED = 1 0 <= angle <= 360, 0 <= angle <= PI * 2 RANGE__SIGNED = 2 -180 <= angle <= 180, -PI <= angle <= PI

Enumerator:
RANGE__UNLIMITED 
RANGE__UNSIGNED 
RANGE__SIGNED 

Constructor & Destructor Documentation

template<typename T >
BALL::TAngle< T >::TAngle ( )

Default constructor. Creates a new angle object. Its value is set to 0.

template<typename T >
BALL::TAngle< T >::TAngle ( const TAngle< T > &  angle)

Copy constructor. Create a copy of a TAngle object. Copies are always shallow.

Parameters:
anglethe object to be copied
template<typename T>
BALL::TAngle< T >::TAngle ( const T &  new_value,
bool  radian = true 
) [explicit]

Detailed constructor. Create a new angle object and set its value to new_value. radian determines whether new_value is in radians or in degrees.

Parameters:
new_valuethe value of the angle object
radiantrue if new_value is in radians, false otherwise
template<typename T>
virtual BALL::TAngle< T >::~TAngle ( ) [inline, virtual]

Destructor.


Member Function Documentation

template<typename T>
virtual void BALL::TAngle< T >::clear ( ) [inline, virtual]

Clear method The value is set to 0.

template<typename T >
void BALL::TAngle< T >::dump ( std::ostream &  s = std::cout,
Size  depth = 0 
) const

Internal state dump. Dump the current internal state of {*this} to the output ostream s with dumping depth depth .

Parameters:
s- output stream where to output the internal state of {*this}
depth- the dumping depth

References BALL_DUMP_DEPTH, BALL_DUMP_HEADER, BALL_DUMP_STREAM_PREFIX, and BALL_DUMP_STREAM_SUFFIX.

template<typename T>
void BALL::TAngle< T >::get ( T &  val,
bool  radian = true 
) const

Assign the value to a variable of type T.

Parameters:
valthe variable to assign the value to
radianif set to true assigns the value in radians (default).

References BALL_ANGLE_RADIAN_TO_DEGREE.

template<typename T >
void BALL::TAngle< T >::get ( TAngle< T > &  angle) const

Assign the value to another angle.

Parameters:
anglethe angle to assign the value to

References BALL::TAngle< T >::value.

template<typename T >
bool BALL::TAngle< T >::isEquivalent ( TAngle< T >  angle) const

Test whether two angles are equivalent. Both angles are normalized and afterwards compared with Maths::isEqual instead of comparing the values directly.

Parameters:
anglethe angle to compare with
Returns:
bool, true if {*this} angle is equal to value

References BALL::TAngle< T >::normalize().

template<typename T >
bool BALL::TAngle< T >::isValid ( ) const

Test whether instance is valid. Always returns true

Returns:
bool true
template<typename T >
void BALL::TAngle< T >::negate ( )

Negate the angle

template<typename T >
void BALL::TAngle< T >::normalize ( Range  range)

Normalize the angle over a given range. RANGE__UNLIMITED = 0 no limitations. RANGE__UNSIGNED = 1 $0 \le \mathtt{angle} \le 360, 0 \le angle \le 2 \pi$. RANGE__SIGNED = 2 $-180 \le \mathtt{angle} \le 180, -\pi \le \mathtt{angle} \le \pi$.

Parameters:
rangethe range of the angle

References BALL::Maths::isGreater(), BALL::Maths::isLess(), and BALL::Constants::PI.

Referenced by BALL::TAngle< T >::isEquivalent().

template<typename T >
BALL::TAngle< T >::operator T ( ) const

Cast operator

Returns:
value in radians
template<typename T >
bool BALL::TAngle< T >::operator!= ( const TAngle< T > &  angle) const

Inequality operator This test uses Maths::isNotEqual instead of comparing the values directly.

Parameters:
anglethe angle to compare with
Returns:
bool, true if the two angles are not equal

References BALL::Maths::isNotEqual(), and BALL::TAngle< T >::value.

template<typename T >
TAngle< T > & BALL::TAngle< T >::operator*= ( const TAngle< T > &  angle)

Multiply an angle with this angle.

Parameters:
anglethe angle to multiply by
Returns:
TAngle, {*this}

References BALL::TAngle< T >::value.

template<typename T>
TAngle< T > & BALL::TAngle< T >::operator*= ( const T &  val)

Multiply a value with this angle.

Parameters:
valthe value to multiply by
Returns:
TAngle, {*this}
template<typename T >
TAngle< T > BALL::TAngle< T >::operator+ ( ) const

Positive sign.

template<typename T >
TAngle< T > BALL::TAngle< T >::operator+ ( const TAngle< T > &  angle)

Addition operator.

Parameters:
anglethe angle to add
Returns:
TAngle, the new angle

References BALL::TAngle< T >::value.

template<typename T >
TAngle< T > & BALL::TAngle< T >::operator+= ( const TAngle< T > &  angle)

Addition operator.

Parameters:
anglethe angle to add
Returns:
TAngle, {*this}

References BALL::TAngle< T >::value.

template<typename T>
TAngle< T > & BALL::TAngle< T >::operator+= ( const T &  val)

Add a value to this angle.

Parameters:
valthe value to add
Returns:
TAngle, {*this}
template<typename T >
TAngle< T > BALL::TAngle< T >::operator- ( ) const

Negative sign.

template<typename T >
TAngle< T > BALL::TAngle< T >::operator- ( const TAngle< T > &  angle)

Subtraction an angle from this angle.

Parameters:
anglethe angle to substract
Returns:
TAngle, the new angle

References BALL::TAngle< T >::value.

template<typename T >
TAngle< T > & BALL::TAngle< T >::operator-= ( const TAngle< T > &  angle)

Substraction operator.

Parameters:
anglethe angle to substract
Returns:
TAngle, {*this}

References BALL::TAngle< T >::value.

template<typename T>
TAngle< T > & BALL::TAngle< T >::operator-= ( const T &  val)

Substract a value from this angle.

Parameters:
valthe value to substract
Returns:
TAngle, {*this}
template<typename T >
TAngle< T > BALL::TAngle< T >::operator/ ( const TAngle< T > &  val) throw (Exception::DivisionByZero)

Divide this angle by a value.

Parameters:
valthe angle to divide by
Returns:
TAngle, the new angle
template<typename T >
TAngle< T > & BALL::TAngle< T >::operator/= ( const TAngle< T > &  angle) throw (Exception::DivisionByZero)

Division operator.

Parameters:
anglethe angle to divide by
Returns:
TAngle, {*this}
template<typename T>
TAngle< T > & BALL::TAngle< T >::operator/= ( const T &  val) throw (Exception::DivisionByZero)

Divide this angle by a value.

Parameters:
valthe angle to divide by
Returns:
TAngle, {*this}
template<typename T>
bool BALL::TAngle< T >::operator< ( const T &  val) const

Is less operator. This test uses Maths::isLess instead of comparing the values directly.

Parameters:
valthe value to compare with
Returns:
bool, true if {*this} angle is smaller than value

References BALL::Maths::isLess().

template<typename T >
bool BALL::TAngle< T >::operator< ( const TAngle< T > &  angle) const

Is less operator. This test uses Maths::isLess instead of comparing the values directly.

Parameters:
anglethe angle to compare with
Returns:
bool, true if {*this} angle is smaller than value

References BALL::Maths::isLess(), and BALL::TAngle< T >::value.

template<typename T >
bool BALL::TAngle< T >::operator<= ( const TAngle< T > &  angle) const

Is less or equal operator. This test uses Maths::isLessOrEqual instead of comparing the values directly.

Parameters:
anglethe angle to compare with
Returns:
bool, true if {*this} angle is smaller or equal than value

References BALL::Maths::isLessOrEqual(), and BALL::TAngle< T >::value.

template<typename T >
TAngle< T > & BALL::TAngle< T >::operator= ( const TAngle< T > &  angle)

Assignment operator

References BALL::TAngle< T >::value.

template<typename T>
TAngle< T > & BALL::TAngle< T >::operator= ( const T &  new_value)

Assignment operator for floats. Assign a float value to the angle. The assigned value has to be in radians!

Parameters:
new_valuethe new value
template<typename T >
bool BALL::TAngle< T >::operator== ( const TAngle< T > &  angle) const

Equality operator. This test uses Maths::isEqual instead of comparing the values directly.

Parameters:
anglethe angle to compare with
Returns:
bool, true if the two angles are equal

References BALL::Maths::isEqual(), and BALL::TAngle< T >::value.

template<typename T >
bool BALL::TAngle< T >::operator> ( const TAngle< T > &  angle) const

Is greater operator. This test uses Maths::isGreater instead of comparing the values directly.

Parameters:
anglethe angle to compare with
Returns:
bool, true if {*this} angle is greater than value

References BALL::Maths::isGreater(), and BALL::TAngle< T >::value.

template<typename T >
bool BALL::TAngle< T >::operator>= ( const TAngle< T > &  angle) const

Is greater or equal operator. This test uses Maths::isGreaterOrEqual instead of comparing the values directly.

Parameters:
anglethe angle to compare with
Returns:
bool, true if {*this} angle is greater or equal than value

References BALL::Maths::isGreaterOrEqual(), and BALL::TAngle< T >::value.

template<typename T>
void BALL::TAngle< T >::set ( const T &  new_value,
bool  radian = true 
)

Assign a new value to the angle. radian determines whether new_value is in radians or in degrees.

Parameters:
new_valuethe value of the angle object
radiantrue if new_value is in radians, false otherwise

References BALL_ANGLE_DEGREE_TO_RADIAN.

template<typename T>
void BALL::TAngle< T >::set ( const TAngle< T > &  angle)

Assign an Angle object from another.

Parameters:
anglethe angle object to be assigned from

References BALL::TAngle< T >::value.

template<typename T >
void BALL::TAngle< T >::swap ( TAngle< T > &  angle)

Swap the contents of two angles.

References BALL::TAngle< T >::value.

template<typename T>
T BALL::TAngle< T >::toDegree ( const T &  radian) [static]

Calculate degrees from radians

Parameters:
radianthe value in radians
Returns:
T the value in degrees

References BALL_ANGLE_RADIAN_TO_DEGREE.

template<typename T >
T BALL::TAngle< T >::toDegree ( ) const

Return the value of the angle

Returns:
value in degrees

References BALL_ANGLE_RADIAN_TO_DEGREE.

template<typename T >
T BALL::TAngle< T >::toRadian ( ) const

Return the value of the angle

Returns:
value in radians
template<typename T>
T BALL::TAngle< T >::toRadian ( const T &  degree) [static]

Calculate radians from degrees

Parameters:
degreethe value in degrees
Returns:
T the value in radians

References BALL_ANGLE_DEGREE_TO_RADIAN.


Member Data Documentation