Ogre::Euler Class Reference

Class for Euler rotations. More...

#include <euler.h>

Public Member Functions

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

Protected Attributes

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

Friends

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

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 25 of file euler.h.

Constructor & Destructor Documentation

◆ Euler() [1/7]

Ogre::Euler::Euler ( )
inline

Default constructor.

Definition at line 29 of file euler.h.

◆ Euler() [2/7]

Ogre::Euler::Euler ( Radian  y,
Radian  p = Radian(0.0f),
Radian  r = 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 40 of file euler.h.

◆ Euler() [3/7]

Ogre::Euler::Euler ( int  y,
int  p = 0,
int  r = 0 
)
inline

Constructor which takes yaw, pitch and roll values as ints (degrees).

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

Definition at line 51 of file euler.h.

◆ Euler() [4/7]

Ogre::Euler::Euler ( Real  y,
Real  p = 0.0f,
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 62 of file euler.h.

◆ Euler() [5/7]

Ogre::Euler::Euler ( Vector3  axvec)
inline

Default constructor with presets.

Parameters
axvecStarting values as a combined vector

Definition at line 71 of file euler.h.

◆ Euler() [6/7]

Ogre::Euler::Euler ( const Euler copyFrom)
inline

Copy constructor.

Parameters
copyFromEuler vector the new one is copied from

Definition at line 80 of file euler.h.

◆ Euler() [7/7]

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

Default constructor with presets.

Parameters
quaternionCalculate starting values from this quaternion

Definition at line 89 of file euler.h.

Member Function Documentation

◆ fromQuaternion()

void Ogre::Euler::fromQuaternion ( Quaternion  quaternion)
inline

Calculate the current Euler of a given quaternion object.

Parameters
quaternionQuaternion which is used to calculate current euler angles

Definition at line 232 of file euler.h.

◆ getForward()

Vector3 Ogre::Euler::getForward ( )
inline

Get a vector pointing forwards.

Definition at line 200 of file euler.h.

◆ getPitch()

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

Get the Pitch angle.

Definition at line 98 of file euler.h.

Here is the caller graph for this function:

◆ getRight()

Vector3 Ogre::Euler::getRight ( )
inline

Get a vector pointing to the right.

Definition at line 203 of file euler.h.

◆ getRoll()

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

Get the Roll angle.

Definition at line 101 of file euler.h.

Here is the caller graph for this function:

◆ getRotationTo()

Euler Ogre::Euler::getRotationTo ( const Vector3 &  dir,
bool  setYaw = true,
bool  setPitch = true,
bool  shortest = true 
) const
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 365 of file euler.h.

Here is the call graph for this function:

◆ getUp()

Vector3 Ogre::Euler::getUp ( )
inline

Get a vector pointing up.

Definition at line 206 of file euler.h.

◆ getYaw()

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

Get the Yaw angle.

Definition at line 95 of file euler.h.

Here is the caller graph for this function:

◆ limitPitch()

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

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

Definition at line 394 of file euler.h.

◆ limitRoll()

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

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

Definition at line 410 of file euler.h.

◆ limitYaw()

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

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

Definition at line 378 of file euler.h.

◆ normalise()

void 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 278 of file euler.h.

Here is the caller graph for this function:

◆ operator Quaternion()

Ogre::Euler::operator Quaternion ( )
inline

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

Definition at line 223 of file euler.h.

◆ operator*() [1/3]

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

Interpolate the euler angles by rhs.

Definition at line 448 of file euler.h.

◆ operator*() [2/3]

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 458 of file euler.h.

◆ operator*() [3/3]

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

Apply the euler rotation to the vector rhs.

Definition at line 465 of file euler.h.

◆ operator+() [1/2]

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

Add two euler objects.

Definition at line 433 of file euler.h.

◆ operator+() [2/2]

Euler Ogre::Euler::operator+ ( const Vector3 &  angles) const
inline

Add a vector with radiant euler angles.

Definition at line 436 of file euler.h.

◆ operator-() [1/2]

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

Subtract two euler objects.

This finds the difference as relative angles.

Definition at line 442 of file euler.h.

◆ operator-() [2/2]

Euler Ogre::Euler::operator- ( const Vector3 &  angles) const
inline

Subtract a vector with radiant euler angles.

Definition at line 445 of file euler.h.

◆ operator=() [1/2]

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

Copy assignment operator (Euler)

Definition at line 468 of file euler.h.

Here is the call graph for this function:

◆ operator=() [2/2]

Euler Ogre::Euler::operator= ( Vector3  pyr)
inline

Copy assignment operator (Quaternion)

Copy assignment operator (Vector3)

Definition at line 482 of file euler.h.

◆ pitch()

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

Apply a relative pitch.

Parameters
pAngle to add on current pitch

Definition at line 166 of file euler.h.

◆ roll()

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

Apply a relative roll.

Parameters
rAngle to add on current roll

Definition at line 177 of file euler.h.

◆ rotate()

Euler& Ogre::Euler::rotate ( Radian  y,
Radian  p,
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 190 of file euler.h.

◆ setDirection()

Euler& Ogre::Euler::setDirection ( const 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 259 of file euler.h.

Here is the caller graph for this function:

◆ setPitch()

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

Set the pitch.

Parameters
pNew value for pitch

Definition at line 118 of file euler.h.

◆ setRoll()

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

Set the roll.

Parameters
rNew value for roll

Definition at line 129 of file euler.h.

◆ setRotation()

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

Set all rotations at once.

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

Definition at line 142 of file euler.h.

◆ setYaw()

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

Set the yaw.

Parameters
yNew value for yaw

Definition at line 107 of file euler.h.

◆ toQuaternion()

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 212 of file euler.h.

◆ yaw()

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

Apply a relative yaw.

Parameters
yAngle to add on current yaw

Definition at line 155 of file euler.h.

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ operator*

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

Interpolate the euler angle by lhs.

Definition at line 451 of file euler.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 426 of file euler.h.

Member Data Documentation

◆ mCachedQuaternion

Quaternion Ogre::Euler::mCachedQuaternion
protected

Cached quaternion equivalent of this Euler object.

Definition at line 492 of file euler.h.

◆ mChanged

bool Ogre::Euler::mChanged
protected

Is the cached quaternion out of date?

Definition at line 493 of file euler.h.

◆ mPitch

Radian Ogre::Euler::mPitch
protected

Rotation around the X axis.

Definition at line 490 of file euler.h.

◆ mRoll

Radian Ogre::Euler::mRoll
protected

Rotation around the Z axis.

Definition at line 491 of file euler.h.

◆ mYaw

Radian Ogre::Euler::mYaw
protected

Rotation around the Y axis.

Definition at line 489 of file euler.h.


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