Ion
|
The Rotation class represents a rotation around a 3-dimensional axis. More...
#include "rotation.h"
Public Types | |
typedef Angle< T > | AngleType |
Convenience typedefs for Angle and 3D vector of the correct type. More... | |
typedef Vector< 3, T > | VectorType |
typedef Vector< 4, T > | QuaternionType |
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 QuaternionType & | GetQuaternion () 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... | |
Rotation & | operator*= (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, T > | operator* (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) |
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.
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.
typedef Vector<4, T> ion::math::Rotation< T >::QuaternionType |
Definition at line 42 of file rotation.h.
typedef Vector<3, T> ion::math::Rotation< T >::VectorType |
Definition at line 41 of file rotation.h.
|
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().
|
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().
|
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().
|
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().
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().
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.
|
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().
|
inlinestatic |
Returns an identity Rotation, which has no effect.
Definition at line 51 of file rotation.h.
References ion::math::Rotation< T >::Rotation().
|
inline |
Returns true if this represents an identity Rotation.
Definition at line 56 of file rotation.h.
const VectorType ion::math::Rotation< T >::operator* | ( | const VectorType & | v | ) | const |
Multiply a Rotation and a Vector/Point to get a Vector/Point.
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().
|
inline |
Appends a rotation to this one.
Definition at line 118 of file rotation.h.
References ion::math::Rotation< T >::SetQuaternion().
|
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().
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>>().
|
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().
|
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().
Definition at line 144 of file rotation.h.
|
friend |
Binary multiplication operator - returns a composite Rotation.
Definition at line 130 of file rotation.h.
The negation operator returns the inverse rotation.
Definition at line 111 of file rotation.h.
Exact equality and inequality comparisons.
Definition at line 141 of file rotation.h.