ReactPhysics3D  v0.10.2
C++ Physics engine library
Loading...
Searching...
No Matches
reactphysics3d::Quaternion Struct Reference

This class represents a quaternion. More...

#include <include/reactphysics3d/mathematics/Quaternion.h>

Public Member Functions

 Quaternion ()
 Constructor.
 
 Quaternion (decimal newX, decimal newY, decimal newZ, decimal newW)
 Constructor with arguments.
 
 Quaternion (decimal newW, const Vector3 &v)
 Constructor with the component w and the vector v=(x y z)
 
 Quaternion (const Vector3 &v, decimal newW)
 Constructor with the component w and the vector v=(x y z)
 
 Quaternion (const Matrix3x3 &matrix)
 Create a unit quaternion from a rotation matrix.
 
void setAllValues (decimal newX, decimal newY, decimal newZ, decimal newW)
 Set all the values.
 
void setToZero ()
 Set the quaternion to zero.
 
void setToIdentity ()
 Set to the identity quaternion.
 
Vector3 getVectorV () const
 Return the vector v=(x y z) of the quaternion.
 
decimal length () const
 Return the length of the quaternion.
 
decimal lengthSquare () const
 Return the square of the length of the quaternion.
 
void normalize ()
 Normalize the quaternion.
 
void inverse ()
 Inverse the quaternion.
 
Quaternion getUnit () const
 Return the unit quaternion.
 
Quaternion getConjugate () const
 Return the conjugate quaternion.
 
Quaternion getInverse () const
 Return the inverse of the quaternion.
 
Matrix3x3 getMatrix () const
 Return the orientation matrix corresponding to this quaternion.
 
decimal dot (const Quaternion &quaternion) const
 Dot product between two quaternions.
 
void getRotationAngleAxis (decimal &angle, Vector3 &axis) const
 Compute the rotation angle (in radians) and the rotation axis.
 
bool isFinite () const
 Return true if the values are not NAN OR INF.
 
bool isUnit () const
 Return true if it is a unit quaternion.
 
bool isValid () const
 Return true if it is a valid quaternion.
 
Quaternion operator+ (const Quaternion &quaternion) const
 Overloaded operator for the addition.
 
Quaternion operator- (const Quaternion &quaternion) const
 Overloaded operator for the substraction.
 
Quaternionoperator+= (const Quaternion &quaternion)
 Overloaded operator for addition with assignment.
 
Quaternionoperator-= (const Quaternion &quaternion)
 Overloaded operator for substraction with assignment.
 
Quaternion operator* (decimal nb) const
 Overloaded operator for the multiplication with a constant.
 
Quaternion operator* (const Quaternion &quaternion) const
 Overloaded operator for the multiplication.
 
Vector3 operator* (const Vector3 &point) const
 Overloaded operator for the multiplication with a vector.
 
bool operator== (const Quaternion &quaternion) const
 Overloaded operator for equality condition.
 
std::string to_string () const
 Return the string representation.
 

Static Public Member Functions

static Quaternion identity ()
 Return the identity quaternion.
 
static Quaternion fromEulerAngles (decimal angleX, decimal angleY, decimal angleZ)
 Return a quaternion constructed from Euler angles (in radians)
 
static Quaternion fromEulerAngles (const Vector3 &eulerAngles)
 Return a quaternion constructed from Euler angles (in radians)
 
static Quaternion slerp (const Quaternion &quaternion1, const Quaternion &quaternion2, decimal t)
 Compute the spherical linear interpolation between two quaternions.
 

Public Attributes

decimal x
 Component x.
 
decimal y
 Component y.
 
decimal z
 Component z.
 
decimal w
 Component w.
 

Detailed Description

This class represents a quaternion.

We use the notation : q = (x*i, y*j, z*k, w) to represent a quaternion.

Member Function Documentation

◆ getRotationAngleAxis()

void Quaternion::getRotationAngleAxis ( decimal &  angle,
Vector3 axis 
) const

Compute the rotation angle (in radians) and the rotation axis.

This method is used to get the rotation angle (in radian) and the unit rotation axis of an orientation quaternion.

◆ operator*()

RP3D_FORCE_INLINE Vector3 reactphysics3d::Quaternion::operator* ( const Vector3 point) const

Overloaded operator for the multiplication with a vector.

This methods rotates a point given the rotation of a quaternion.

◆ slerp()

Quaternion Quaternion::slerp ( const Quaternion quaternion1,
const Quaternion quaternion2,
decimal  t 
)
static

Compute the spherical linear interpolation between two quaternions.

The t argument has to be such that 0 <= t <= 1. This method is static.


The documentation for this struct was generated from the following files: