39 Euler(
const Ogre::Radian &y,
const Ogre::Radian &p = Ogre::Radian(0.0f),
const Ogre::Radian &r = Ogre::Radian(0.0f))
50 Euler(Ogre::Real y, Ogre::Real p = 0.0f, Ogre::Real r = 0.0f)
59 explicit Euler(
const Ogre::Quaternion &quaternion)
64 explicit Euler(
const Ogre::Matrix3 &matrix)
117 inline Euler &
setRotation(
const Ogre::Radian &y,
const Ogre::Radian &p,
const Ogre::Radian &r)
165 inline Euler &
rotate(
const Ogre::Radian &y,
const Ogre::Radian &p,
const Ogre::Radian &r)
191 mCachedQuaternion = Ogre::Quaternion(
mYaw, Ogre::Vector3::UNIT_Y) * Ogre::Quaternion(
mPitch, Ogre::Vector3::UNIT_X) * Ogre::Quaternion(
mRoll, Ogre::Vector3::UNIT_Z);
198 inline operator Ogre::Quaternion()
209 Ogre::Matrix3 rotmat;
210 quaternion.ToRotationMatrix(rotmat);
234 Ogre::Vector3 d(v.normalisedCopy());
236 mPitch = Ogre::Math::ASin(d.y);
238 mYaw = Ogre::Math::ATan2(-d.x, -d.z);
250 inline Euler &
normalise(
bool normYaw =
true,
bool normPitch =
true,
bool normRoll =
true)
254 Ogre::Real
yaw =
mYaw.valueRadians();
255 if(
yaw < -Ogre::Math::PI)
257 yaw = fmod(
yaw, Ogre::Math::PI * 2.0f);
258 if(
yaw < -Ogre::Math::PI)
260 yaw += Ogre::Math::PI * 2.0f;
265 else if(
yaw > Ogre::Math::PI)
267 yaw = fmod(
yaw, Ogre::Math::PI * 2.0f);
268 if(
yaw > Ogre::Math::PI)
270 yaw -= Ogre::Math::PI * 2.0f;
279 if(
pitch < -Ogre::Math::PI)
282 if(
pitch < -Ogre::Math::PI)
284 pitch += Ogre::Math::PI * 2.0f;
289 else if(
pitch > Ogre::Math::PI)
292 if(
pitch > Ogre::Math::PI)
294 pitch -= Ogre::Math::PI * 2.0f;
303 if(
roll < -Ogre::Math::PI)
305 roll = fmod(
roll, Ogre::Math::PI * 2.0f);
306 if(
roll < -Ogre::Math::PI)
308 roll += Ogre::Math::PI * 2.0f;
313 else if(
roll > Ogre::Math::PI)
315 roll = fmod(
roll, Ogre::Math::PI * 2.0f);
316 if(
roll > Ogre::Math::PI)
318 roll -= Ogre::Math::PI * 2.0f;
359 else if(
mYaw < -limit)
391 else if(
mRoll < -limit)
402 o <<
"<Y:" << e.
mYaw <<
", P:" << e.
mPitch <<
", R:" << e.
mRoll <<
">";
440 Euler e1(*
this), e2(rhs);
445 inline Ogre::Vector3
operator*(
const Ogre::Vector3 &rhs)
Class for Euler rotations.
friend Euler operator*(Ogre::Real lhs, const Euler &rhs)
Interpolate the euler angle by lhs.
Ogre::Radian mPitch
Rotation around the X axis.
bool mChanged
Is the cached quaternion out of date?
Euler & rotate(const Ogre::Radian &y, const Ogre::Radian &p, const Ogre::Radian &r)
Apply all relative rotations at once.
Euler & limitYaw(const Ogre::Radian &limit)
Clamp the yaw angle to a range of +/-limit.
Euler & setPitch(Ogre::Radian p)
Set the pitch.
Euler()
Default constructor.
Ogre::Radian mYaw
Rotation around the Y axis.
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 specifi...
Ogre::Vector3 getUp()
Get a vector pointing up.
Ogre::Radian getYaw() const
Get the Yaw angle.
Euler & fromMatrix3(const Ogre::Matrix3 &matrix)
Calculate the current euler angles of a given matrix object.
Ogre::Vector3 operator*(const Ogre::Vector3 &rhs)
Apply the euler rotation to the vector rhs.
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 & yaw(const Ogre::Radian &y)
Apply a relative yaw.
Ogre::Vector3 getForward()
Get a vector pointing forwards.
Euler & fromQuaternion(const Ogre::Quaternion &quaternion)
Calculate the current euler angles of a given quaternion object.
Ogre::Vector3 getRight()
Get a vector pointing to the right.
Ogre::Quaternion toQuaternion()
Calculate the quaternion of the euler object.
Euler & roll(const Ogre::Radian &r)
Apply a relative roll.
Euler(const Ogre::Matrix3 &matrix)
Euler & operator=(const Euler &src)
Copy assignment operator (Euler)
Euler & operator=(const Ogre::Matrix3 &matrix)
Copy assignment operator (Matrix3)
Ogre::Radian getRoll() const
Get the Roll angle.
Ogre::Quaternion operator*(const Euler &rhs) const
Multiply two eulers.
Euler & pitch(const Ogre::Radian &p)
Apply a relative pitch.
Ogre::Quaternion mCachedQuaternion
Cached quaternion equivalent of this euler object.
Euler(const Ogre::Quaternion &quaternion)
Default constructor with presets.
Euler & normalise(bool normYaw=true, bool normPitch=true, bool normRoll=true)
Normalise the selected rotations to be within the +/-180 degree range.
Euler operator-(const Euler &rhs) const
Subtract two euler objects.
Euler & setRoll(Ogre::Radian r)
Set the roll.
Euler & setRotation(const Ogre::Radian &y, const Ogre::Radian &p, const Ogre::Radian &r)
Set all rotations at once.
Euler & setYaw(Ogre::Radian y)
Set the yaw.
Euler & limitRoll(const Ogre::Radian &limit)
Clamp the roll angle to a range of +/-limit.
Euler & setDirection(const Ogre::Vector3 &v, bool setYaw=true, bool setPitch=true)
Set the yaw and pitch to face in the given direction.
Euler & limitPitch(const Ogre::Radian &limit)
Clamp the pitch angle to a range of +/-limit.
Ogre::Radian getPitch() const
Get the Pitch angle.
friend std::ostream & operator<<(std::ostream &o, const Euler &e)
Stream operator, for printing the euler component angles to a stream.
Euler operator*(Ogre::Real rhs) const
Interpolate the euler angles by rhs.
Euler & operator=(const Ogre::Quaternion &quaternion)
Copy assignment operator (Quaternion)
Ogre::Radian mRoll
Rotation around the Z axis.
Euler operator+(const Euler &rhs) const
Add two euler objects.
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.