Skylicht Engine
Loading...
Searching...
No Matches
irr::core::quaternion Class Reference

Quaternion class for representing rotations. More...

#include <C:/Projects/skylicht-engine/Projects/Irrlicht/Include/quaternion.h>

Public Member Functions

 quaternion ()
 Default Constructor.
 quaternion (f32 x, f32 y, f32 z, f32 w)
 Constructor.
 quaternion (f32 x, f32 y, f32 z)
 Constructor which converts euler angles (radians) to a quaternion.
 quaternion (const vector3df &vec)
 Constructor which converts euler angles (radians) to a quaternion.
 quaternion (const matrix4 &mat)
 Constructor which converts a matrix to a quaternion.
bool operator== (const quaternion &other) const
 Equalilty operator.
bool operator!= (const quaternion &other) const
 inequality operator
quaternionoperator= (const quaternion &other)
 Assignment operator.
quaternionoperator= (const matrix4 &other)
 Matrix assignment operator.
quaternion operator+ (const quaternion &other) const
 Add operator.
quaternion operator* (const quaternion &other) const
 Multiplication operator.
quaternion operator* (f32 s) const
 Multiplication operator with scalar.
quaternionoperator*= (f32 s)
 Multiplication operator with scalar.
vector3df operator* (const vector3df &v) const
 Multiplication operator.
quaternionoperator*= (const quaternion &other)
 Multiplication operator.
f32 dotProduct (const quaternion &other) const
 Calculates the dot product.
quaternionset (f32 x, f32 y, f32 z, f32 w)
 Sets new quaternion.
quaternionset (f32 x, f32 y, f32 z)
 Sets new quaternion based on euler angles (radians).
quaternionset (const core::vector3df &vec)
 Sets new quaternion based on euler angles (radians).
quaternionset (const core::quaternion &quat)
 Sets new quaternion from other quaternion.
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
quaternionnormalize ()
 Normalizes the quaternion.
matrix4 getMatrix () const
 Creates a matrix from this quaternion.
void getMatrix (matrix4 &dest, const core::vector3df &translation) const
 Creates a matrix from this quaternion.
void getMatrix (matrix4 &dest) const
void getMatrixCenter (matrix4 &dest, const core::vector3df &center, const core::vector3df &translation) const
void getMatrix_transposed (matrix4 &dest) const
 Creates a matrix from this quaternion.
quaternionmakeInverse ()
 Inverts this quaternion.
quaternionlerp (quaternion q1, quaternion q2, f32 time)
 Set this quaternion to the linear interpolation between two quaternions.
quaternionslerp (quaternion q1, quaternion q2, f32 time, f32 threshold=.05f)
 Set this quaternion to the result of the spherical interpolation between two quaternions.
quaternionfromAngleAxis (f32 angle, const vector3df &axis)
 Create quaternion from rotation angle and rotation axis.
void toAngleAxis (f32 &angle, core::vector3df &axis) const
 Fills an angle (radians) around an axis (unit vector).
void toEuler (vector3df &euler) const
 Output this quaternion to an euler angle (radians).
quaternionmakeIdentity ()
 Set quaternion to identity.
quaternionrotationFromTo (const vector3df &from, const vector3df &to)
 Set quaternion to represent a rotation from one vector to another.

Public Attributes

f32 X
 Quaternion elements.
f32 Y
f32 Z
f32 W

Detailed Description

Quaternion class for representing rotations.

It provides cheap combinations and avoids gimbal locks. Also useful for interpolations.

Member Function Documentation

◆ fromAngleAxis()

quaternion & irr::core::quaternion::fromAngleAxis ( f32 angle,
const vector3df & axis )
inline

Create quaternion from rotation angle and rotation axis.

axis must be unit length, angle in radians

Axis must be unit length. The quaternion representing the rotation is q = cos(A/2)+sin(A/2)*(x*i+y*j+z*k).

Parameters
angleRotation Angle in radians.
axisRotation axis.

◆ getMatrix()

void irr::core::quaternion::getMatrix ( matrix4 & dest) const
inline

Creates a matrix from this quaternion

◆ getMatrixCenter()

void irr::core::quaternion::getMatrixCenter ( matrix4 & dest,
const core::vector3df & center,
const core::vector3df & translation ) const
inline

Creates a matrix from this quaternion Rotate about a center point shortcut for core::quaternion q; q.rotationFromTo ( vin[i].Normal, forward ); q.getMatrixCenter ( lookat, center, newPos );

core::matrix4 m2; m2.setInverseTranslation ( center ); lookat *= m2;

core::matrix4 m3; m2.setTranslation ( newPos ); lookat *= m3;

Creates a matrix from this quaternion Rotate about a center point shortcut for core::quaternion q; q.rotationFromTo(vin[i].Normal, forward); q.getMatrix(lookat, center);

core::matrix4 m2; m2.setInverseTranslation(center); lookat *= m2;

◆ lerp()

quaternion & irr::core::quaternion::lerp ( quaternion q1,
quaternion q2,
f32 time )
inline

Set this quaternion to the linear interpolation between two quaternions.

Parameters
q1First quaternion to be interpolated.
q2Second quaternion to be interpolated.
timeProgress of interpolation. For time=0 the result is q1, for time=1 the result is q2. Otherwise interpolation between q1 and q2.

◆ slerp()

quaternion & irr::core::quaternion::slerp ( quaternion q1,
quaternion q2,
f32 time,
f32 threshold = .05f )
inline

Set this quaternion to the result of the spherical interpolation between two quaternions.

Parameters
q1First quaternion to be interpolated.
q2Second quaternion to be interpolated.
timeProgress of interpolation. For time=0 the result is q1, for time=1 the result is q2. Otherwise interpolation between q1 and q2.
thresholdTo avoid inaccuracies at the end (time=1) the interpolation switches to linear interpolation at some point. This value defines how much of the remaining interpolation will be calculated with lerp. Everything from 1-threshold up will be linear interpolation.

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