Project

General

Profile

SO3Engine

Class for Euler rotations. More...

#include <SO3Euler.h>

Public Member Functions

 Euler ()
 Default constructor.
 
 Euler (const Ogre::Radian &y, const Ogre::Radian &p=Ogre::Radian(0.0f), const Ogre::Radian &r=Ogre::Radian(0.0f))
 Constructor which takes yaw, pitch and roll values.

 
 Euler (Ogre::Real y, Ogre::Real p=0.0f, Ogre::Real r=0.0f)
 Constructor which takes yaw, pitch and roll values as reals (radians).
 
 Euler (const Ogre::Quaternion &quaternion)
 Default constructor with presets.
 
 Euler (const Ogre::Matrix3 &matrix)
 
Ogre::Radian getYaw () const
 Get the Yaw angle.
 
Ogre::Radian getPitch () const
 Get the Pitch angle.
 
Ogre::Radian getRoll () const
 Get the Roll angle.
 
EulersetYaw (Ogre::Radian y)
 Set the yaw.
 
EulersetPitch (Ogre::Radian p)
 Set the pitch.
 
EulersetRoll (Ogre::Radian r)
 Set the roll.
 
EulersetRotation (const Ogre::Radian &y, const Ogre::Radian &p, const Ogre::Radian &r)
 Set all rotations at once.
 
Euleryaw (const Ogre::Radian &y)
 Apply a relative yaw.
 
Eulerpitch (const Ogre::Radian &p)
 Apply a relative pitch.
 
Eulerroll (const Ogre::Radian &r)
 Apply a relative roll.
 
Eulerrotate (const Ogre::Radian &y, const Ogre::Radian &p, const Ogre::Radian &r)
 Apply all relative rotations at once.
 
Ogre::Vector3 getForward ()
 Get a vector pointing forwards.
 
Ogre::Vector3 getRight ()
 Get a vector pointing to the right.
 
Ogre::Vector3 getUp ()
 Get a vector pointing up.
 
Ogre::Quaternion toQuaternion ()
 Calculate the quaternion of the euler object.
 
 operator Ogre::Quaternion ()
 Casting operator. This allows any ogre function that wants a Quaternion to accept a Euler instead.
 
EulerfromQuaternion (const Ogre::Quaternion &quaternion)
 Calculate the current euler angles of a given quaternion object.
 
EulerfromMatrix3 (const Ogre::Matrix3 &matrix)
 Calculate the current euler angles of a given matrix object.
 
EulersetDirection (const Ogre::Vector3 &v, bool setYaw=true, bool setPitch=true)
 Set the yaw and pitch to face in the given direction.
 
Eulernormalise (bool normYaw=true, bool normPitch=true, bool normRoll=true)
 Normalise the selected rotations to be within the +/-180 degree range.
 
Euler getRotationTo (const Ogre::Vector3 &dir, bool setYaw=true, bool setPitch=true, bool shortest=true)
 Return the relative euler angles required to rotate from the current forward direction to the specified dir vector.
 
EulerlimitYaw (const Ogre::Radian &limit)
 Clamp the yaw angle to a range of +/-limit.
 
EulerlimitPitch (const Ogre::Radian &limit)
 Clamp the pitch angle to a range of +/-limit.
 
EulerlimitRoll (const Ogre::Radian &limit)
 Clamp the roll angle to a range of +/-limit.
 
Euler operator+ (const Euler &rhs) const
 Add two euler objects.
 
Euler operator- (const Euler &rhs) const
 Subtract two euler objects.
 
Euler operator* (Ogre::Real rhs) const
 Interpolate the euler angles by rhs.
 
Ogre::Quaternion operator* (const Euler &rhs) const
 Multiply two eulers.
 
Ogre::Vector3 operator* (const Ogre::Vector3 &rhs)
 Apply the euler rotation to the vector rhs.
 
Euleroperator= (const Euler &src)
 Copy assignment operator (Euler)
 
Euleroperator= (const Ogre::Quaternion &quaternion)
 Copy assignment operator (Quaternion)
 
Euleroperator= (const Ogre::Matrix3 &matrix)
 Copy assignment operator (Matrix3)
 

Protected Attributes

Ogre::Radian mYaw
 Rotation around the Y axis.
 
Ogre::Radian mPitch
 Rotation around the X axis.
 
Ogre::Radian mRoll
 Rotation around the Z axis.
 
Ogre::Quaternion mCachedQuaternion
 Cached quaternion equivalent of this euler object.
 
bool mChanged
 Is the cached quaternion out of date?
 

Friends

std::ostream & operator<< (std::ostream &o, const Euler &e)
 Stream operator, for printing the euler component angles to a stream.
 
Euler operator* (Ogre::Real lhs, const Euler &rhs)
 Interpolate the euler angle by lhs.
 

Detailed Description

Class for Euler rotations.

Yaw is a rotation around the Y axis.Pitch is a rotation around the X axis.Roll is a rotation around the Z axis.

Definition at line 24 of file SO3Euler.h.

Constructor & Destructor Documentation

◆ Euler() [1/5]

Ogre::Euler::Euler ( )
inline

Default constructor.

Definition at line 28 of file SO3Euler.h.

◆ Euler() [2/5]

Ogre::Euler::Euler ( const Ogre::Radian &  y,
const Ogre::Radian &  p = Ogre::Radian(0.0f),
const Ogre::Radian &  r = Ogre::Radian(0.0f) 
)
inline

Constructor which takes yaw, pitch and roll values.

Parameters
yStarting value for yaw
pStarting value for pitch
rStarting value for roll

Definition at line 39 of file SO3Euler.h.

◆ Euler() [3/5]

Ogre::Euler::Euler ( Ogre::Real  y,
Ogre::Real  p = 0.0f,
Ogre::Real  r = 0.0f 
)
inline

Constructor which takes yaw, pitch and roll values as reals (radians).

Parameters
yStarting value for yaw [radian]
pStarting value for pitch [radian]
rStarting value for roll [radian]

Definition at line 50 of file SO3Euler.h.

◆ Euler() [4/5]

Ogre::Euler::Euler ( const Ogre::Quaternion &  quaternion)
inlineexplicit

Default constructor with presets.

Parameters
quaternionCalculate starting values from this quaternion

Definition at line 59 of file SO3Euler.h.

◆ Euler() [5/5]

Ogre::Euler::Euler ( const Ogre::Matrix3 &  matrix)
inlineexplicit

Definition at line 64 of file SO3Euler.h.

Member Function Documentation

◆ fromMatrix3()

Euler & Ogre::Euler::fromMatrix3 ( const Ogre::Matrix3 &  matrix)
inline

Calculate the current euler angles of a given matrix object.

Parameters
matrixMatrix3 which is used to calculate current euler angles.

Definition at line 219 of file SO3Euler.h.

◆ fromQuaternion()

Euler & Ogre::Euler::fromQuaternion ( const Ogre::Quaternion &  quaternion)
inline

Calculate the current euler angles of a given quaternion object.

Parameters
quaternionQuaternion which is used to calculate current euler angles.

Definition at line 207 of file SO3Euler.h.

◆ getForward()

Ogre::Vector3 Ogre::Euler::getForward ( )
inline

Get a vector pointing forwards.

Definition at line 175 of file SO3Euler.h.

◆ getPitch()

Ogre::Radian Ogre::Euler::getPitch ( ) const
inline

Get the Pitch angle.

Definition at line 73 of file SO3Euler.h.

◆ getRight()

Ogre::Vector3 Ogre::Euler::getRight ( )
inline

Get a vector pointing to the right.

Definition at line 178 of file SO3Euler.h.

◆ getRoll()

Ogre::Radian Ogre::Euler::getRoll ( ) const
inline

Get the Roll angle.

Definition at line 76 of file SO3Euler.h.

◆ getRotationTo()

Euler Ogre::Euler::getRotationTo ( const Ogre::Vector3 &  dir,
bool  setYaw = true,
bool  setPitch = true,
bool  shortest = true 
)
inline

Return the relative euler angles required to rotate from the current forward direction to the specified dir vector.

The result euler can then be added to the current euler to immediately face dir. The rotation won't flip upside down then roll instead of a 180 degree yaw.

Parameters
setYawIf false, the angle is set to 0. If true, the angle is calculated.
setPitchIf false, the angle is set to 0. If true, the angle is calculated.
shortestIf false, the full value of each angle is used. If true, the angles are normalised and the shortest rotation is found to face the correct direction. For example, when false a yaw of 1000 degrees and a dir of (0,0,-1) will return a -1000 degree yaw. When true, the same yaw and dir would give 80 degrees (1080 degrees faces the same way as (0,0,-1).

Definition at line 338 of file SO3Euler.h.

◆ getUp()

Ogre::Vector3 Ogre::Euler::getUp ( )
inline

Get a vector pointing up.

Definition at line 181 of file SO3Euler.h.

◆ getYaw()

Ogre::Radian Ogre::Euler::getYaw ( ) const
inline

Get the Yaw angle.

Definition at line 70 of file SO3Euler.h.

◆ limitPitch()

Euler & Ogre::Euler::limitPitch ( const Ogre::Radian &  limit)
inline

Clamp the pitch angle to a range of +/-limit.

Definition at line 368 of file SO3Euler.h.

◆ limitRoll()

Euler & Ogre::Euler::limitRoll ( const Ogre::Radian &  limit)
inline

Clamp the roll angle to a range of +/-limit.

Definition at line 384 of file SO3Euler.h.

◆ limitYaw()

Euler & Ogre::Euler::limitYaw ( const Ogre::Radian &  limit)
inline

Clamp the yaw angle to a range of +/-limit.

Definition at line 352 of file SO3Euler.h.

◆ normalise()

Euler & Ogre::Euler::normalise ( bool  normYaw = true,
bool  normPitch = true,
bool  normRoll = true 
)
inline

Normalise the selected rotations to be within the +/-180 degree range.

The normalise uses a wrap around, so for example a yaw of 360 degrees becomes 0 degrees, and -190 degrees becomes 170.

Parameters
normYawIf false, the yaw isn't normalized.
normPitchIf false, the pitch isn't normalized.
normRollIf false, the roll isn't normalized.

Definition at line 250 of file SO3Euler.h.

◆ operator Ogre::Quaternion()

Ogre::Euler::operator Ogre::Quaternion ( )
inline

Casting operator. This allows any ogre function that wants a Quaternion to accept a Euler instead.

Definition at line 198 of file SO3Euler.h.

◆ operator*() [1/3]

Ogre::Quaternion Ogre::Euler::operator* ( const Euler rhs) const
inline

Multiply two eulers.

This has the same effect as multiplying quaternions.

Returns
The result is a quaternion.

Definition at line 438 of file SO3Euler.h.

◆ operator*() [2/3]

Ogre::Vector3 Ogre::Euler::operator* ( const Ogre::Vector3 &  rhs)
inline

Apply the euler rotation to the vector rhs.

Definition at line 445 of file SO3Euler.h.

◆ operator*() [3/3]

Euler Ogre::Euler::operator* ( Ogre::Real  rhs) const
inline

Interpolate the euler angles by rhs.

Definition at line 422 of file SO3Euler.h.

◆ operator+()

Euler Ogre::Euler::operator+ ( const Euler rhs) const
inline

Add two euler objects.

Definition at line 407 of file SO3Euler.h.

◆ operator-()

Euler Ogre::Euler::operator- ( const Euler rhs) const
inline

Subtract two euler objects.

This finds the difference as relative angles.

Definition at line 416 of file SO3Euler.h.

◆ operator=() [1/3]

Euler & Ogre::Euler::operator= ( const Euler src)
inline

Copy assignment operator (Euler)

Definition at line 451 of file SO3Euler.h.

◆ operator=() [2/3]

Euler & Ogre::Euler::operator= ( const Ogre::Matrix3 &  matrix)
inline

Copy assignment operator (Matrix3)

Definition at line 465 of file SO3Euler.h.

◆ operator=() [3/3]

Euler & Ogre::Euler::operator= ( const Ogre::Quaternion &  quaternion)
inline

Copy assignment operator (Quaternion)

Definition at line 458 of file SO3Euler.h.

◆ pitch()

Euler & Ogre::Euler::pitch ( const Ogre::Radian &  p)
inline

Apply a relative pitch.

Parameters
pAngle to add on current pitch

Definition at line 141 of file SO3Euler.h.

◆ roll()

Euler & Ogre::Euler::roll ( const Ogre::Radian &  r)
inline

Apply a relative roll.

Parameters
rAngle to add on current roll

Definition at line 152 of file SO3Euler.h.

◆ rotate()

Euler & Ogre::Euler::rotate ( const Ogre::Radian &  y,
const Ogre::Radian &  p,
const Ogre::Radian &  r 
)
inline

Apply all relative rotations at once.

Parameters
yAngle to add on current yaw
pAngle to add on current pitch
rAngle to add on current roll

Definition at line 165 of file SO3Euler.h.

◆ setDirection()

Euler & Ogre::Euler::setDirection ( const Ogre::Vector3 &  v,
bool  setYaw = true,
bool  setPitch = true 
)
inline

Set the yaw and pitch to face in the given direction.

The direction doesn't need to be normalised. Roll is always unaffected.

Parameters
setYawIf false, the yaw isn't changed.
setPitchIf false, the pitch isn't changed.

Definition at line 232 of file SO3Euler.h.

◆ setPitch()

Euler & Ogre::Euler::setPitch ( Ogre::Radian  p)
inline

Set the pitch.

Parameters
pNew value for pitch

Definition at line 93 of file SO3Euler.h.

◆ setRoll()

Euler & Ogre::Euler::setRoll ( Ogre::Radian  r)
inline

Set the roll.

Parameters
rNew value for roll

Definition at line 104 of file SO3Euler.h.

◆ setRotation()

Euler & Ogre::Euler::setRotation ( const Ogre::Radian &  y,
const Ogre::Radian &  p,
const Ogre::Radian &  r 
)
inline

Set all rotations at once.

Parameters
yNew value for yaw
pNew value for pitch
rNew value for roll

Definition at line 117 of file SO3Euler.h.

◆ setYaw()

Euler & Ogre::Euler::setYaw ( Ogre::Radian  y)
inline

Set the yaw.

Parameters
yNew value for yaw

Definition at line 82 of file SO3Euler.h.

◆ toQuaternion()

Ogre::Quaternion Ogre::Euler::toQuaternion ( )
inline

Calculate the quaternion of the euler object.

The result is cached, it is only recalculated when the component euler angles are changed.

Definition at line 187 of file SO3Euler.h.

◆ yaw()

Euler & Ogre::Euler::yaw ( const Ogre::Radian &  y)
inline

Apply a relative yaw.

Parameters
yAngle to add on current yaw

Definition at line 130 of file SO3Euler.h.

Friends And Related Symbol Documentation

◆ operator*

Euler operator* ( Ogre::Real  lhs,
const Euler rhs 
)
friend

Interpolate the euler angle by lhs.

Definition at line 428 of file SO3Euler.h.

◆ operator<<

std::ostream & operator<< ( std::ostream &  o,
const Euler e 
)
friend

Stream operator, for printing the euler component angles to a stream.

Definition at line 400 of file SO3Euler.h.

Member Data Documentation

◆ mCachedQuaternion

Ogre::Quaternion Ogre::Euler::mCachedQuaternion
protected

Cached quaternion equivalent of this euler object.

Definition at line 475 of file SO3Euler.h.

◆ mChanged

bool Ogre::Euler::mChanged
protected

Is the cached quaternion out of date?

Definition at line 476 of file SO3Euler.h.

◆ mPitch

Ogre::Radian Ogre::Euler::mPitch
protected

Rotation around the X axis.

Definition at line 473 of file SO3Euler.h.

◆ mRoll

Ogre::Radian Ogre::Euler::mRoll
protected

Rotation around the Z axis.

Definition at line 474 of file SO3Euler.h.

◆ mYaw

Ogre::Radian Ogre::Euler::mYaw
protected

Rotation around the Y axis.

Definition at line 472 of file SO3Euler.h.


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