Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ion::math::Rotation< T > Class Template Reference

The Rotation class represents a rotation around a 3-dimensional axis. More...

#include "rotation.h"

Public Types

typedef Angle< TAngleType
 Convenience typedefs for Angle and 3D vector of the correct type. More...
 
typedef Vector< 3, TVectorType
 
typedef Vector< 4, TQuaternionType
 

Public Member Functions

 Rotation ()
 The default constructor creates an identity Rotation, which has no effect. More...
 
bool IsIdentity () const
 Returns true if this represents an identity Rotation. More...
 
void SetQuaternion (const QuaternionType &quaternion)
 Sets the Rotation from a quaternion (4D vector), which is first normalized. More...
 
const QuaternionTypeGetQuaternion () const
 Returns the Rotation as a normalized quaternion (4D vector). More...
 
void SetAxisAndAngle (const VectorType &axis, const AngleType &angle)
 Sets the Rotation to rotate by the given angle around the given axis, following the right-hand rule. More...
 
void GetAxisAndAngle (VectorType *axis, AngleType *angle) const
 Returns the right-hand rule axis and angle corresponding to the Rotation. More...
 
void GetEulerAngles (AngleType *yaw, AngleType *pitch, AngleType *roll) const
 Returns the Euler angles which would result in this rotation if done in the order of rotate-Y by yaw, rotate-X by pitch, rotate-Z by roll. More...
 
Rotationoperator*= (const Rotation &r)
 Appends a rotation to this one. More...
 
const VectorType operator* (const VectorType &v) const
 Multiply a Rotation and a Vector/Point to get a Vector/Point. More...
 
const Point< 3, Toperator* (const Point< 3, T > &p) const
 

Static Public Member Functions

static Rotation Identity ()
 Returns an identity Rotation, which has no effect. More...
 
static Rotation FromAxisAndAngle (const VectorType &axis, const AngleType &angle)
 Convenience function that constructs and returns a Rotation given an axis and angle. More...
 
static Rotation FromQuaternion (const QuaternionType &quat)
 Convienance function that constructs and returns a Rotation given a quaternion. More...
 
static Rotation FromRotationMatrix (const Matrix< 3, T > &mat)
 Convienance function that constructs and returns a Rotation given a rotation matrix R with $R^ R = I && det(R) = 1$. More...
 
static Rotation RotateInto (const VectorType &from, const VectorType &to)
 Constructs and returns a Rotation that rotates one vector to another along the shortest arc. More...
 
static Rotation Slerp (const Rotation &r0, const Rotation &r1, T t)
 Performs spherical linear interpolation between two Rotation instances. More...
 

Friends

Rotation operator- (const Rotation &r)
 The negation operator returns the inverse rotation. More...
 
const Rotation operator* (const Rotation &r0, const Rotation &r1)
 Binary multiplication operator - returns a composite Rotation. More...
 
bool operator== (const Rotation &v0, const Rotation &v1)
 Exact equality and inequality comparisons. More...
 
bool operator!= (const Rotation &v0, const Rotation &v1)
 

Detailed Description

template<typename T>
class ion::math::Rotation< T >

The Rotation class represents a rotation around a 3-dimensional axis.

It uses normalized quaternions internally to make the math robust.

Definition at line 37 of file rotation.h.

Member Typedef Documentation

template<typename T>
typedef Angle<T> ion::math::Rotation< T >::AngleType

Convenience typedefs for Angle and 3D vector of the correct type.

Definition at line 40 of file rotation.h.

template<typename T>
typedef Vector<4, T> ion::math::Rotation< T >::QuaternionType

Definition at line 42 of file rotation.h.

template<typename T>
typedef Vector<3, T> ion::math::Rotation< T >::VectorType

Definition at line 41 of file rotation.h.

Constructor & Destructor Documentation

template<typename T>
ion::math::Rotation< T >::Rotation ( )
inline

The default constructor creates an identity Rotation, which has no effect.

Definition at line 45 of file rotation.h.

References ion::math::VectorBase< Dimension, T >::Set().

Referenced by ion::math::Rotation< T >::Identity().

Member Function Documentation

template<typename T>
static Rotation ion::math::Rotation< T >::FromAxisAndAngle ( const VectorType axis,
const AngleType angle 
)
inlinestatic

Convenience function that constructs and returns a Rotation given an axis and angle.

Definition at line 85 of file rotation.h.

References ion::math::Rotation< T >::SetAxisAndAngle().

template<typename T>
static Rotation ion::math::Rotation< T >::FromQuaternion ( const QuaternionType quat)
inlinestatic

Convienance function that constructs and returns a Rotation given a quaternion.

Definition at line 94 of file rotation.h.

References ion::math::Rotation< T >::SetQuaternion().

Referenced by ion::math::Rotation< T >::FromRotationMatrix(), and ion::math::Rotation< T >::RotateInto().

template<typename T >
Rotation< T > ion::math::Rotation< T >::FromRotationMatrix ( const Matrix< 3, T > &  mat)
static

Convienance function that constructs and returns a Rotation given a rotation matrix R with $R^ R = I && det(R) = 1$.

Definition at line 52 of file rotation.cc.

References ion::math::Rotation< T >::FromQuaternion(), and ion::math::Sqrt().

template<typename T >
void ion::math::Rotation< T >::GetAxisAndAngle ( VectorType axis,
AngleType angle 
) const

Returns the right-hand rule axis and angle corresponding to the Rotation.

If the Rotation is the identity rotation, this returns the +X axis and an angle of 0.

Definition at line 100 of file rotation.cc.

References ion::math::ArcCosine(), DCHECK, DCHECK_NE, ion::math::Sqrt(), and ion::math::Square().

template<typename T >
void ion::math::Rotation< T >::GetEulerAngles ( AngleType yaw,
AngleType pitch,
AngleType roll 
) const

Returns the Euler angles which would result in this rotation if done in the order of rotate-Y by yaw, rotate-X by pitch, rotate-Z by roll.

Definition at line 115 of file rotation.cc.

References DCHECK.

template<typename T>
const QuaternionType& ion::math::Rotation< T >::GetQuaternion ( ) const
inline

Returns the Rotation as a normalized quaternion (4D vector).

Definition at line 67 of file rotation.h.

Referenced by ion::math::Rotation< T >::Slerp().

template<typename T>
static Rotation ion::math::Rotation< T >::Identity ( )
inlinestatic

Returns an identity Rotation, which has no effect.

Definition at line 51 of file rotation.h.

References ion::math::Rotation< T >::Rotation().

template<typename T>
bool ion::math::Rotation< T >::IsIdentity ( ) const
inline

Returns true if this represents an identity Rotation.

Definition at line 56 of file rotation.h.

template<typename T>
const VectorType ion::math::Rotation< T >::operator* ( const VectorType v) const

Multiply a Rotation and a Vector/Point to get a Vector/Point.

template<typename T >
const Point< 3, T > ion::math::Rotation< T >::operator* ( const Point< 3, T > &  p) const

Definition at line 179 of file rotation.h.

References ion::math::Point< Dimension, T >::Zero().

template<typename T>
Rotation& ion::math::Rotation< T >::operator*= ( const Rotation< T > &  r)
inline

Appends a rotation to this one.

Definition at line 118 of file rotation.h.

References ion::math::Rotation< T >::SetQuaternion().

template<typename T >
Rotation< T > ion::math::Rotation< T >::RotateInto ( const VectorType from,
const VectorType to 
)
static

Constructs and returns a Rotation that rotates one vector to another along the shortest arc.

This returns an identity rotation if either vector has zero length.

Definition at line 150 of file rotation.cc.

References ion::math::Abs(), ion::math::Cross(), ion::math::Dot(), ion::math::Rotation< T >::FromQuaternion(), ion::math::LengthSquared(), and ion::math::Sqrt().

template<typename T >
void ion::math::Rotation< T >::SetAxisAndAngle ( const VectorType axis,
const AngleType angle 
)

Sets the Rotation to rotate by the given angle around the given axis, following the right-hand rule.

Rotation functions.

The axis does not need to be unit length. If it is zero length, this results in an identity Rotation.

Definition at line 39 of file rotation.cc.

References ion::math::Cosine(), ion::math::Normalize(), and ion::math::Sine().

Referenced by ion::math::Rotation< T >::FromAxisAndAngle(), and ion::math::operator>>().

template<typename T>
void ion::math::Rotation< T >::SetQuaternion ( const QuaternionType quaternion)
inline

Sets the Rotation from a quaternion (4D vector), which is first normalized.

Definition at line 62 of file rotation.h.

References ion::math::Normalized().

Referenced by ion::math::Rotation< T >::FromQuaternion(), ion::math::Rotation< T >::operator*=(), and ion::math::Rotation< T >::Slerp().

template<typename T >
Rotation< T > ion::math::Rotation< T >::Slerp ( const Rotation< T > &  r0,
const Rotation< T > &  r1,
T  t 
)
static

Performs spherical linear interpolation between two Rotation instances.

This returns r0 when t is 0 and r1 when t is 1; all other values of t interpolate appropriately.

Definition at line 178 of file rotation.cc.

References ion::math::ArcCosine(), ion::math::Clamp(), ion::math::Cosine(), ion::math::Dot(), ion::math::Rotation< T >::GetQuaternion(), ion::math::Normalized(), ion::math::Rotation< T >::SetQuaternion(), and ion::math::Sine().

Friends And Related Function Documentation

template<typename T>
bool operator!= ( const Rotation< T > &  v0,
const Rotation< T > &  v1 
)
friend

Definition at line 144 of file rotation.h.

template<typename T>
const Rotation operator* ( const Rotation< T > &  r0,
const Rotation< T > &  r1 
)
friend

Binary multiplication operator - returns a composite Rotation.

Definition at line 130 of file rotation.h.

template<typename T>
Rotation operator- ( const Rotation< T > &  r)
friend

The negation operator returns the inverse rotation.

Definition at line 111 of file rotation.h.

template<typename T>
bool operator== ( const Rotation< T > &  v0,
const Rotation< T > &  v1 
)
friend

Exact equality and inequality comparisons.

Definition at line 141 of file rotation.h.


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