Nazara Engine
0.4
A fast, complete, cross-platform API designed for game development
|
Math class that represents an element of the quaternions. More...
Public Member Functions | |
Quaternion (T W, T X, T Y, T Z) | |
Constructs a Quaternion object from its components. More... | |
Quaternion (const EulerAngles< T > &angles) | |
Constructs a Quaternion object from a EulerAngles. More... | |
Quaternion (T angle, const Vector3< T > &axis) | |
Constructs a Quaternion object from an angle and a direction. More... | |
Quaternion (const T quat[4]) | |
Constructs a Quaternion object from an array of four elements. More... | |
template<typename U > | |
Quaternion (const Quaternion< U > &quat) | |
Constructs a Quaternion object from another type of Quaternion. More... | |
Quaternion (const Quaternion &quat)=default | |
Quaternion & | ComputeW () |
Computes the w component of the quaternion to make it unit. More... | |
Quaternion & | Conjugate () |
Returns the rotational conjugate of this quaternion. More... | |
T | DotProduct (const Quaternion &vec) const |
Calculates the dot (scalar) product with two quaternions. More... | |
Quaternion | GetConjugate () const |
Gets the rotational conjugate of this quaternion. More... | |
Quaternion | GetInverse () const |
Gets the inverse of this quaternion. More... | |
Quaternion | GetNormal (T *length=nullptr) const |
Gets the normalization of this quaternion. More... | |
Quaternion & | Inverse () |
Inverts this quaternion. More... | |
Quaternion & | MakeIdentity () |
Makes the quaternion (1, 0, 0, 0) More... | |
Quaternion & | MakeRotationBetween (const Vector3< T > &from, const Vector3< T > &to) |
Makes this quaternion to the rotation required to rotate direction Vector3 from to direction Vector3 to. More... | |
Quaternion & | MakeZero () |
Makes the quaternion (0, 0, 0, 0) More... | |
T | Magnitude () const |
Calculates the magnitude (length) of the quaternion. More... | |
Quaternion & | Normalize (T *length=nullptr) |
Normalizes the current quaternion. More... | |
Quaternion & | Set (T W, T X, T Y, T Z) |
Sets the components of the quaternion. More... | |
Quaternion & | Set (const EulerAngles< T > &angles) |
Sets this quaternion from rotation specified by Euler angle. More... | |
Quaternion & | Set (T angle, const Vector3< T > &normalizedAxis) |
Sets this quaternion from rotation specified by axis and angle. More... | |
Quaternion & | Set (const T quat[4]) |
Sets the components of the quaternion from an array of four elements. More... | |
Quaternion & | Set (const Quaternion &quat) |
Sets the components of the quaternion from another quaternion. More... | |
template<typename U > | |
Quaternion & | Set (const Quaternion< U > &quat) |
T | SquaredMagnitude () const |
Calculates the squared magnitude (length) of the quaternion. More... | |
EulerAngles< T > | ToEulerAngles () const |
Converts this quaternion to Euler angles representation. More... | |
String | ToString () const |
Gives a string representation. More... | |
Quaternion & | operator= (const Quaternion &quat)=default |
Quaternion | operator+ (const Quaternion &quat) const |
Adds the components of the quaternion with other quaternion. More... | |
Quaternion | operator* (const Quaternion &quat) const |
Multiplies of the quaternion with other quaternion. More... | |
Vector3< T > | operator* (const Vector3< T > &vec) const |
Apply the quaternion to the Vector3. More... | |
Quaternion | operator* (T scale) const |
Multiplies the components of the quaternion with a scalar. More... | |
Quaternion | operator/ (const Quaternion &quat) const |
Divides the quaternion with other quaternion. More... | |
Quaternion & | operator+= (const Quaternion &quat) |
Adds the components of the quaternion with other quaternion. More... | |
Quaternion & | operator*= (const Quaternion &quat) |
Multiplies of the quaternion with other quaternion. More... | |
Quaternion & | operator*= (T scale) |
Multiplies the components of the quaternion with a scalar. More... | |
Quaternion & | operator/= (const Quaternion &quat) |
Divides the quaternion with other quaternion. More... | |
bool | operator== (const Quaternion &quat) const |
Compares the quaternion to other one. More... | |
bool | operator!= (const Quaternion &quat) const |
Compares the quaternion to other one. More... | |
template<typename U > | |
Quaternion< T > & | Set (const Quaternion< U > &quat) |
Sets the components of the quaternion from another type of Quaternion. More... | |
Static Public Member Functions | |
static Quaternion | Identity () |
Shorthand for the quaternion (1, 0, 0, 0) More... | |
static Quaternion | Lerp (const Quaternion &from, const Quaternion &to, T interpolation) |
Interpolates the quaternion to other one with a factor of interpolation. More... | |
static Quaternion | Normalize (const Quaternion &quat, T *length=nullptr) |
Gives the normalized quaternion. More... | |
static Quaternion | RotationBetween (const Vector3< T > &from, const Vector3< T > &to) |
Gets the rotation required to rotate direction Vector3 from to direction Vector3 to. More... | |
static Quaternion | Slerp (const Quaternion &from, const Quaternion &to, T interpolation) |
Interpolates spherically the quaternion to other one with a factor of interpolation. More... | |
static Quaternion | Zero () |
Shorthand for the quaternion (0, 0, 0, 0) More... | |
Public Attributes | |
T | w |
T | x |
T | y |
T | z |
Math class that represents an element of the quaternions.
Nz::Quaternion< T >::Quaternion | ( | T | W, |
T | X, | ||
T | Y, | ||
T | Z | ||
) |
Constructs a Quaternion object from its components.
W | W component |
X | X component |
Y | Y component |
Z | Z component |
Nz::Quaternion< T >::Quaternion | ( | const EulerAngles< T > & | angles | ) |
Constructs a Quaternion object from a EulerAngles.
angles | Easier representation of rotation of space |
Nz::Quaternion< T >::Quaternion | ( | T | angle, |
const Vector3< T > & | axis | ||
) |
Constructs a Quaternion object from an angle and a direction.
angle | Unit depends of NAZARA_MATH_ANGLE_RADIAN |
axis | Vector3 which represents a direction, no need to be normalized |
Nz::Quaternion< T >::Quaternion | ( | const T | quat[4] | ) |
Constructs a Quaternion object from an array of four elements.
quat[4] | quat[0] is W component, quat[1] is X component, quat[2] is Y component and quat[3] is Z component |
|
explicit |
Constructs a Quaternion object from another type of Quaternion.
quat | Quaternion of type U to convert to type T |
Quaternion< T > & Nz::Quaternion< T >::ComputeW | ( | ) |
Computes the w component of the quaternion to make it unit.
Quaternion< T > & Nz::Quaternion< T >::Conjugate | ( | ) |
Returns the rotational conjugate of this quaternion.
The conjugate of a quaternion represents the same rotation in the opposite direction about the rotational axis
T Nz::Quaternion< T >::DotProduct | ( | const Quaternion< T > & | quat | ) | const |
Calculates the dot (scalar) product with two quaternions.
quat | The other quaternion to calculate the dot product with |
Quaternion< T > Nz::Quaternion< T >::GetConjugate | ( | ) | const |
Gets the rotational conjugate of this quaternion.
The conjugate of a quaternion represents the same rotation in the opposite direction about the rotational axis
Quaternion< T > Nz::Quaternion< T >::GetInverse | ( | ) | const |
Gets the inverse of this quaternion.
Quaternion< T > Nz::Quaternion< T >::GetNormal | ( | T * | length = nullptr | ) | const |
Gets the normalization of this quaternion.
length | Optional argument to obtain the length's ratio of the quaternion and the unit-length |
|
static |
Shorthand for the quaternion (1, 0, 0, 0)
Quaternion< T > & Nz::Quaternion< T >::Inverse | ( | ) |
Inverts this quaternion.
|
static |
Interpolates the quaternion to other one with a factor of interpolation.
from | Initial quaternion |
to | Target quaternion |
interpolation | Factor of interpolation |
T Nz::Quaternion< T >::Magnitude | ( | ) | const |
Quaternion< T > & Nz::Quaternion< T >::MakeIdentity | ( | ) |
Makes the quaternion (1, 0, 0, 0)
Quaternion< T > & Nz::Quaternion< T >::MakeRotationBetween | ( | const Vector3< T > & | from, |
const Vector3< T > & | to | ||
) |
Makes this quaternion to the rotation required to rotate direction Vector3 from to direction Vector3 to.
from | Initial vector |
to | Target vector |
Quaternion< T > & Nz::Quaternion< T >::MakeZero | ( | ) |
Makes the quaternion (0, 0, 0, 0)
Quaternion< T > & Nz::Quaternion< T >::Normalize | ( | T * | length = nullptr | ) |
Normalizes the current quaternion.
length | Optional argument to obtain the length's ratio of the quaternion and the unit-length |
|
static |
Gives the normalized quaternion.
quat | Quaternion to normalize |
length | Optional argument to obtain the length's ratio of the vector and the unit-length |
bool Nz::Quaternion< T >::operator!= | ( | const Quaternion< T > & | quat | ) | const |
Compares the quaternion to other one.
vec | Other quaternion to compare with |
Quaternion< T > Nz::Quaternion< T >::operator* | ( | const Quaternion< T > & | quat | ) | const |
Multiplies of the quaternion with other quaternion.
quat | The other quaternion to multiply with |
Vector3< T > Nz::Quaternion< T >::operator* | ( | const Vector3< T > & | vec | ) | const |
Apply the quaternion to the Vector3.
vec | The vector to multiply with |
Quaternion< T > Nz::Quaternion< T >::operator* | ( | T | scale | ) | const |
Multiplies the components of the quaternion with a scalar.
scale | The scalar to multiply components with |
Quaternion< T > & Nz::Quaternion< T >::operator*= | ( | const Quaternion< T > & | quat | ) |
Multiplies of the quaternion with other quaternion.
quat | The other quaternion to multiply with |
Quaternion< T > & Nz::Quaternion< T >::operator*= | ( | T | scale | ) |
Multiplies the components of the quaternion with a scalar.
scale | The scalar to multiply components with |
Quaternion< T > Nz::Quaternion< T >::operator+ | ( | const Quaternion< T > & | quat | ) | const |
Adds the components of the quaternion with other quaternion.
quat | The other quaternion to add components with |
Quaternion< T > & Nz::Quaternion< T >::operator+= | ( | const Quaternion< T > & | quat | ) |
Adds the components of the quaternion with other quaternion.
quat | The other quaternion to add components with |
Quaternion< T > Nz::Quaternion< T >::operator/ | ( | const Quaternion< T > & | quat | ) | const |
Divides the quaternion with other quaternion.
quat | The other quaternion to divide with |
Quaternion< T > & Nz::Quaternion< T >::operator/= | ( | const Quaternion< T > & | quat | ) |
Divides the quaternion with other quaternion.
quat | The other quaternion to divide with |
bool Nz::Quaternion< T >::operator== | ( | const Quaternion< T > & | quat | ) | const |
Compares the quaternion to other one.
vec | Other quaternion to compare with |
|
static |
Gets the rotation required to rotate direction Vector3 from to direction Vector3 to.
from | Initial vector |
to | Target vector |
Quaternion< T > & Nz::Quaternion< T >::Set | ( | T | W, |
T | X, | ||
T | Y, | ||
T | Z | ||
) |
Sets the components of the quaternion.
W | W component |
X | X component |
Y | Y component |
Z | Z component |
Quaternion< T > & Nz::Quaternion< T >::Set | ( | const EulerAngles< T > & | angles | ) |
Sets this quaternion from rotation specified by Euler angle.
angles | Easier representation of rotation of space |
Quaternion< T > & Nz::Quaternion< T >::Set | ( | T | angle, |
const Vector3< T > & | axis | ||
) |
Sets this quaternion from rotation specified by axis and angle.
angle | Unit depends of NAZARA_MATH_ANGLE_RADIAN |
axis | Vector3 which represents a direction, no need to be normalized |
Quaternion< T > & Nz::Quaternion< T >::Set | ( | const T | quat[4] | ) |
Sets the components of the quaternion from an array of four elements.
quat[4] | quat[0] is W component, quat[1] is X component, quat[2] is Y component and quat[3] is Z component |
Quaternion< T > & Nz::Quaternion< T >::Set | ( | const Quaternion< T > & | quat | ) |
Sets the components of the quaternion from another quaternion.
vec | The other quaternion |
Quaternion<T>& Nz::Quaternion< T >::Set | ( | const Quaternion< U > & | quat | ) |
Sets the components of the quaternion from another type of Quaternion.
quat | Quaternion of type U to convert its components |
|
static |
Interpolates spherically the quaternion to other one with a factor of interpolation.
from | Initial quaternion |
to | Target quaternion |
interpolation | Factor of interpolation |
T Nz::Quaternion< T >::SquaredMagnitude | ( | ) | const |
Calculates the squared magnitude (length) of the quaternion.
EulerAngles< T > Nz::Quaternion< T >::ToEulerAngles | ( | ) | const |
Converts this quaternion to Euler angles representation.
String Nz::Quaternion< T >::ToString | ( | ) | const |
Gives a string representation.
|
static |
Shorthand for the quaternion (0, 0, 0, 0)