36 #ifndef __Quaternion_H__
37 #define __Quaternion_H__
62 : w(1), x(0), y(0), z(0)
69 : w(fW), x(fX), y(fY), z(fZ)
75 this->FromRotationMatrix(rot);
80 this->FromAngleAxis(rfAngle, rkAxis);
85 this->FromAxes(xaxis, yaxis, zaxis);
90 this->FromAxes(akAxis);
95 memcpy(&w, valptr,
sizeof(
Real)*4);
109 inline Real operator [] (
const size_t i )
const
117 inline Real& operator [] (
const size_t i )
136 void FromRotationMatrix (
const Matrix3& kRot);
137 void ToRotationMatrix (
Matrix3& kRot)
const;
141 void FromAngleAxis (
const Radian& rfAngle,
const Vector3& rkAxis);
145 ToAngleAxis ( rAngle, rkAxis );
151 void FromAxes (
const Vector3* akAxis);
154 void ToAxes (
Vector3* akAxis)
const;
189 return (rhs.
x == x) && (rhs.
y == y) &&
190 (rhs.
z == z) && (rhs.
w == w);
204 Real normalise(
void);
222 Radian getRoll(
bool reprojectAxis =
true)
const;
232 Radian getPitch(
bool reprojectAxis =
true)
const;
242 Radian getYaw(
bool reprojectAxis =
true)
const;
257 Real d = this->Dot(other);
258 return 1 - d*d < tolerance;
274 const Quaternion& rkQ,
bool shortestPath =
false);
285 static void Intermediate (
const Quaternion& rkQ0,
292 const Quaternion& rkQ,
bool shortestPath =
false);
309 const Quaternion& rkQ,
bool shortestPath =
false);
329 inline _OgreExport friend std::ostream&
operator <<
332 o <<
"Quaternion(" << q.w <<
", " << q.x <<
", " << q.y <<
", " << q.z <<
")";
Quaternion(const Radian &rfAngle, const Vector3 &rkAxis)
Construct a quaternion from an angle/axis.
bool orientationEquals(const Quaternion &other, Real tolerance=1e-3) const
Compare two quaternions which are assumed to be used as orientations.
Real * ptr()
Pointer accessor for direct copying.
void swap(Quaternion &other)
Exchange the contents of this quaternion with another.
float Real
Software floating point type.
void ToAngleAxis(Degree &dAngle, Vector3 &rkAxis) const
A 3x3 matrix which can represent rotations around axes.
Quaternion(const Matrix3 &rot)
Construct a quaternion from a rotation matrix.
bool isNaN() const
Check whether this quaternion contains valid values.
Quaternion(const Vector3 &xaxis, const Vector3 &yaxis, const Vector3 &zaxis)
Construct a quaternion from 3 orthonormal local axes.
Radian operator*(Real a, const Radian &b)
const Real * ptr() const
Pointer accessor for direct copying.
Implementation of a Quaternion, i.e.
Quaternion(Real *valptr)
Construct a quaternion from 4 manual w/x/y/z values.
Quaternion(const Vector3 *akAxis)
Construct a quaternion from 3 orthonormal local axes.
static const Quaternion IDENTITY
Quaternion()
Default constructor, initializes to identity rotation (aka 0°)
static const Quaternion ZERO
Wrapper class which indicates a given angle value is in Degrees.
void swap(Ogre::SmallVectorImpl< T > &LHS, Ogre::SmallVectorImpl< T > &RHS)
Implement std::swap in terms of SmallVector swap.
Standard 3-dimensional vector.
Wrapper class which indicates a given angle value is in Radians.
static bool isNaN(Real f)
Quaternion(Real fW, Real fX, Real fY, Real fZ)
Construct from an explicit list of values.
bool operator==(STLAllocator< T, P > const &, STLAllocator< T2, P > const &)
determine equality, can memory from another allocator be released by this allocator, (ISO C++)
bool operator!=(STLAllocator< T, P > const &, STLAllocator< T2, P > const &)
determine equality, can memory from another allocator be released by this allocator, (ISO C++)
static const Real msEpsilon
Cutoff for sine near zero.