5#ifndef __IRR_QUATERNION_H_INCLUDED__
6#define __IRR_QUATERNION_H_INCLUDED__
16#define IRR_TEST_BROKEN_QUATERNION_USE 0
42#if !IRR_TEST_BROKEN_QUATERNION_USE
56#if !IRR_TEST_BROKEN_QUATERNION_USE
101#if !IRR_TEST_BROKEN_QUATERNION_USE
199#if !IRR_TEST_BROKEN_QUATERNION_USE
219 return !(*
this ==
other);
232#if !IRR_TEST_BROKEN_QUATERNION_USE
243 X = (
m[6] -
m[9]) / scale;
244 Y = (
m[8] -
m[2]) / scale;
245 Z = (
m[1] -
m[4]) / scale;
250 if (
m[0]>
m[5] &&
m[0]>
m[10])
254 const f32 scale =
sqrtf(1.0f +
m[0] -
m[5] -
m[10]) * 2.0f;
258 Y = (
m[4] +
m[1]) / scale;
259 Z = (
m[2] +
m[8]) / scale;
260 W = (
m[6] -
m[9]) / scale;
266 const f32 scale =
sqrtf(1.0f +
m[5] -
m[0] -
m[10]) * 2.0f;
269 X = (
m[4] +
m[1]) / scale;
271 Z = (
m[9] +
m[6]) / scale;
272 W = (
m[8] -
m[2]) / scale;
278 const f32 scale =
sqrtf(1.0f +
m[10] -
m[0] -
m[5]) * 2.0f;
281 X = (
m[8] +
m[2]) / scale;
282 Y = (
m[9] +
m[6]) / scale;
284 W = (
m[1] -
m[4]) / scale;
327 return (*
this =
other * (*
this));
336#if !IRR_TEST_BROKEN_QUATERNION_USE
352 dest[0] = 1.0f - 2.0f*
Y*
Y - 2.0f*
Z*
Z;
358 dest[5] = 1.0f - 2.0f*
X*
X - 2.0f*
Z*
Z;
364 dest[10] = 1.0f - 2.0f*
X*
X - 2.0f*
Y*
Y;
372 dest.setDefinitelyIdentityMatrix (
false );
392 dest[0] = 1.0f - 2.0f*
Y*
Y - 2.0f*
Z*
Z;
398 dest[5] = 1.0f - 2.0f*
X*
X - 2.0f*
Z*
Z;
404 dest[10] = 1.0f - 2.0f*
X*
X - 2.0f*
Y*
Y;
413 dest[0] = 1.0f - 2.0f*
Y*
Y - 2.0f*
Z*
Z;
419 dest[5] = 1.0f - 2.0f*
X*
X - 2.0f*
Z*
Z;
425 dest[10] = 1.0f - 2.0f*
X*
X - 2.0f*
Y*
Y;
433 dest.setDefinitelyIdentityMatrix(
false);
526 return (*
this = (
q1*scale) + (
q2*
time));
558 return (
X *
q2.X) + (
Y *
q2.Y) + (
Z *
q2.Z) + (
W *
q2.W);
640 uv =
qvec.crossProduct(v);
676 if (
axis.getLength()==0)
678 axis.set(0.f,1.f,0.f);
4x4 matrix. Mostly used as transformation matrix for 3d calculations.
Axis aligned bounding box in 3d dimensional space.
Quaternion class for representing rotations.
quaternion & operator=(const quaternion &other)
Assignment operator.
f32 dotProduct(const quaternion &other) const
Calculates the dot product.
matrix4 getMatrix() const
Creates a matrix from this quaternion.
quaternion & makeInverse()
Inverts this quaternion.
quaternion & makeIdentity()
Set quaternion to identity.
bool equals(const quaternion &other, const f32 tolerance=ROUNDING_ERROR_f32) const
returns if this quaternion equals the other one, taking floating point rounding errors into account
quaternion & set(f32 x, f32 y, f32 z, f32 w)
Sets new quaternion.
bool operator!=(const quaternion &other) const
inequality operator
void toEuler(vector3df &euler) const
Output this quaternion to an euler angle (radians)
f32 X
Quaternion elements.
bool operator==(const quaternion &other) const
Equalilty operator.
quaternion & lerp(quaternion q1, quaternion q2, f32 time)
Set this quaternion to the linear interpolation between two quaternions.
quaternion(f32 x, f32 y, f32 z, f32 w)
Constructor.
quaternion operator+(const quaternion &other) const
Add operator.
void toAngleAxis(f32 &angle, core::vector3df &axis) const
Fills an angle (radians) around an axis (unit vector)
quaternion & slerp(quaternion q1, quaternion q2, f32 time, f32 threshold=.05f)
Set this quaternion to the result of the spherical interpolation between two quaternions.
quaternion & operator*=(f32 s)
Multiplication operator with scalar.
quaternion & rotationFromTo(const vector3df &from, const vector3df &to)
Set quaternion to represent a rotation from one vector to another.
quaternion & normalize()
Normalizes the quaternion.
void getMatrixCenter(matrix4 &dest, const core::vector3df ¢er, const core::vector3df &translation) const
quaternion & fromAngleAxis(f32 angle, const vector3df &axis)
Create quaternion from rotation angle and rotation axis.
void getMatrix_transposed(matrix4 &dest) const
Creates a matrix from this quaternion.
quaternion operator*(const quaternion &other) const
Multiplication operator.
quaternion()
Default Constructor.
T X
X coordinate of the vector.
T Z
Z coordinate of the vector.
T Y
Y coordinate of the vector.
const f64 PI64
Constant for 64bit PI.
const T clamp(const T &value, const T &low, const T &high)
clamps a value between low and high
const f32 ROUNDING_ERROR_f32
REALINLINE f32 reciprocal(const f32 f)
bool equals(const f64 a, const f64 b, const f64 tolerance=ROUNDING_ERROR_f64)
returns if a equals b, taking possible rounding errors into account
REALINLINE f64 reciprocal_squareroot(const f64 x)
bool iszero(const f64 a, const f64 tolerance=ROUNDING_ERROR_f64)
returns if a equals zero, taking rounding errors into account
Everything in the Irrlicht Engine can be found in this namespace.
float f32
32 bit floating point variable.
double f64
64 bit floating point variable.