Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
Public Types | Public Member Functions | Static Public Attributes | List of all members
jau::math::Quaternion< Value_type, > Class Template Reference

Quaternion implementation supporting Gimbal-Lock free rotations. More...

#include <quaternion.hpp>

Collaboration diagram for jau::math::Quaternion< Value_type, >:

Public Types

typedef const value_typeconst_iterator
 
typedef const value_typeconst_pointer
 
typedef const value_typeconst_reference
 
typedef value_typeiterator
 
typedef value_typepointer
 
typedef value_typereference
 
typedef Value_type value_type
 
typedef Vector3F< value_type, std::is_floating_point_v< Value_type > > Vec3
 

Public Member Functions

constexpr Quaternion () noexcept
 
constexpr Quaternion (const Quaternion &o) noexcept=default
 
constexpr Quaternion (const value_type x, const value_type y, const value_type z, const value_type w) noexcept
 
constexpr Quaternion (Quaternion &&o) noexcept=default
 
constexpr Quaternionconjugate () noexcept
 Conjugates this quaternion [-x, -y, -z, w]. More...
 
constexpr value_type dot (const Quaternion &quat) const noexcept
 Returns the dot product of this quaternion with the given quaternion. More...
 
constexpr value_type dot (value_type x, value_type y, value_type z, value_type w) const noexcept
 Returns the dot product of this quaternion with the given x,y,z and m_w components. More...
 
constexpr Quaternioninvert () noexcept
 Invert the quaternion If rotational, will produce a the inverse rotation. More...
 
constexpr bool isIdentity () const noexcept
 Returns true if this quaternion has identity. More...
 
constexpr_cxx26 value_type magnitude () const noexcept
 Return the magnitude of this quaternion, i.e. More...
 
constexpr value_type magnitudeSquared () const noexcept
 See magnitude() for special handling of epsilon, which is not applied here. More...
 
constexpr Quaternionnormalize () noexcept
 Normalize a quaternion required if to be used as a rotational quaternion. More...
 
constexpr Quaternionoperator*= (const Quaternion &rhs) noexcept
 Multiply this quaternion: this = this * rhs, returns this. More...
 
constexpr Quaternionoperator*= (const value_type rhs) noexcept
 Scale this quaternion by a scalar: this = this * rhs, returns this. More...
 
constexpr Quaternionoperator+= (const Quaternion &rhs) noexcept
 Add a quaternion: this = this + rhs, returns this. More...
 
constexpr Quaternionoperator-= (const Quaternion &rhs) noexcept
 Subtract a quaternion: this = this - rhs, returns this. More...
 
constexpr Quaternionoperator= (const Quaternion &) noexcept=default
 
constexpr Quaternionoperator= (Quaternion &&) noexcept=default
 
constexpr bool operator== (const Quaternion &o) const noexcept
 
constexpr_cxx26 QuaternionrotateByAngleNormalAxis (const value_type angle, const value_type axisX, const value_type axisY, const value_type axisZ) noexcept
 Rotate this quaternion by the given angle and axis. More...
 
constexpr_cxx26 QuaternionrotateByAngleNormalAxis (const value_type angle, const Vec3 &axis) noexcept
 Rotate this quaternion by the given angle and axis. More...
 
constexpr_cxx26 QuaternionrotateByAngleX (const value_type angle) noexcept
 Rotate this quaternion around X axis with the given angle in radians. More...
 
constexpr QuaternionrotateByAngleX (const value_type sin, const value_type cos) noexcept
 Rotate this quaternion around X axis with the given angle's sin + cos values. More...
 
constexpr QuaternionrotateByAngleY (const value_type sin, const value_type cos) noexcept
 Rotate this quaternion around Y axis with the given angle's sin + cos values. More...
 
constexpr_cxx26 QuaternionrotateByAngleY (value_type angle) noexcept
 Rotate this quaternion around Y axis with the given angle in radians. More...
 
constexpr QuaternionrotateByAngleZ (const value_type sin, const value_type cos) noexcept
 Rotate this quaternion around Y axis with the given angle's sin + cos values. More...
 
constexpr_cxx26 QuaternionrotateByAngleZ (value_type angle) noexcept
 Rotate this quaternion around Z axis with the given angle in radians. More...
 
constexpr_cxx26 QuaternionrotateByEuler (const value_type bankX, const value_type headingY, const value_type attitudeZ) noexcept
 Rotates this quaternion from the given Euler rotation angles in radians. More...
 
QuaternionrotateByEuler (const Vec3 &angradXYZ) noexcept
 Rotates this quaternion from the given Euler rotation array angradXYZ in radians. More...
 
Vec3 rotateVector (const Vec3 &in) noexcept
 
Vec3rotateVector (const Vec3 &in, Vec3 &out) noexcept
 
constexpr Quaternionset (const value_type x, const value_type y, const value_type z, const value_type w) noexcept
 Set all values of this quaternion using the given components. More...
 
QuaternionsetFromAngleAxis (const value_type angle, const Vec3 &vector) noexcept
 
constexpr_cxx26 QuaternionsetFromAngleNormalAxis (const value_type angle, const Vec3 &vector) noexcept
 
constexpr QuaternionsetFromAxes (const Vec3 &xAxis, const Vec3 &yAxis, const Vec3 &zAxis) noexcept
 Initializes this quaternion to represent a rotation formed by the given three orthogonal axes. More...
 
constexpr_cxx26 QuaternionsetFromEuler (const value_type bankX, const value_type headingY, const value_type attitudeZ) noexcept
 Initializes this quaternion from the given Euler rotation angles in radians. More...
 
constexpr_cxx26 QuaternionsetFromEuler (const Vec3 &angradXYZ) noexcept
 Initializes this quaternion from the given Euler rotation array angradXYZ in radians. More...
 
constexpr QuaternionsetFromMat (const Mat4f &m) noexcept
 Compute the quaternion from a 3x3 column rotation matrix from mat4f instance. More...
 
constexpr QuaternionsetFromMat (const value_type m00, const value_type m01, const value_type m02, const value_type m10, const value_type m11, const value_type m12, const value_type m20, const value_type m21, const value_type m22) noexcept
 Compute the quaternion from a 3x3 column rotation matrix. More...
 
constexpr_cxx26 QuaternionsetFromNormalVectors (const Vec3 &v1, const Vec3 &v2) noexcept
 Initialize this quaternion from two normalized vectors. More...
 
constexpr_cxx26 QuaternionsetFromVectors (const Vec3 &v1, const Vec3 &v2) noexcept
 Initialize this quaternion from two vectors. More...
 
constexpr QuaternionsetIdentity () noexcept
 
QuaternionsetLookAt (const Vec3 &directionIn, const Vec3 &upIn, Vec3 &xAxisOut, Vec3 &yAxisOut, Vec3 &zAxisOut) noexcept
 Set this quaternion to equal the rotation required to point the z-axis at direction and the y-axis to up. More...
 
constexpr_cxx26 QuaternionsetSlerp (const Quaternion &a, const Quaternion &b, const value_type changeAmnt) noexcept
 Set this quaternion to a spherical linear interpolation between the given start and end quaternions by the given change amount. More...
 
constexpr void setW (value_type w) noexcept
 
constexpr void setX (value_type x) noexcept
 
constexpr void setY (value_type y) noexcept
 
constexpr void setZ (value_type z) noexcept
 
constexpr_cxx26 value_type toAngleAxis (Vec3 &axis) const noexcept
 Transform the rotational quaternion to axis based rotation angles. More...
 
constexpr void toAxes (Vec3 &xAxis, Vec3 &yAxis, Vec3 &zAxis) const noexcept
 Extracts this quaternion's orthogonal rotation axes. More...
 
constexpr void toAxes (Vec3 &xAxis, Vec3 &yAxis, Vec3 &zAxis, Matrix4< value_type > &tmp) const noexcept
 Extracts this quaternion's orthogonal rotation axes. More...
 
constexpr_cxx26 Vec3 toEuler () noexcept
 Transform this quaternion to Euler rotation angles in radians (pitchX, yawY and rollZ). More...
 
constexpr Mat4f toMatrix () const noexcept
 Transform this quaternion to a normalized 4x4 column matrix representing the rotation. More...
 
constexpr Mat4ftoMatrix (Mat4f &m) const noexcept
 Transform this quaternion to a normalized 4x4 column matrix representing the rotation, see toMatrix(). More...
 
std::string toString () const noexcept
 
constexpr value_type w () const noexcept
 
constexpr value_type x () const noexcept
 
constexpr value_type y () const noexcept
 
constexpr value_type z () const noexcept
 

Static Public Attributes

static constexpr const value_type allowed_deviation = value_type(8.4) * std::numeric_limits<value_type>::epsilon()
 Quaternion Epsilon, used with equals method to determine if two Quaternions are close enough to be considered equal. More...
 
static constexpr const value_type half = one/two
 
static constexpr const value_type one = value_type(1)
 
static constexpr const value_type two = value_type(2)
 
static constexpr const value_type zero = value_type(0)
 

Detailed Description

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
class jau::math::Quaternion< Value_type, >

Quaternion implementation supporting Gimbal-Lock free rotations.

All matrix operation provided are in column-major order, as specified in the OpenGL fixed function pipeline, i.e. compatibility profile. See FloatUtil.

See Matrix-FAQ

See euclideanspace.com-Quaternion

Definition at line 62 of file quaternion.hpp.

Member Typedef Documentation

◆ value_type

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
typedef Value_type jau::math::Quaternion< Value_type, >::value_type

Definition at line 64 of file quaternion.hpp.

◆ pointer

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
typedef value_type* jau::math::Quaternion< Value_type, >::pointer

Definition at line 65 of file quaternion.hpp.

◆ const_pointer

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
typedef const value_type* jau::math::Quaternion< Value_type, >::const_pointer

Definition at line 66 of file quaternion.hpp.

◆ reference

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
typedef value_type& jau::math::Quaternion< Value_type, >::reference

Definition at line 67 of file quaternion.hpp.

◆ const_reference

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
typedef const value_type& jau::math::Quaternion< Value_type, >::const_reference

Definition at line 68 of file quaternion.hpp.

◆ iterator

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
typedef value_type* jau::math::Quaternion< Value_type, >::iterator

Definition at line 69 of file quaternion.hpp.

◆ const_iterator

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
typedef const value_type* jau::math::Quaternion< Value_type, >::const_iterator

Definition at line 70 of file quaternion.hpp.

◆ Vec3

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
typedef Vector3F<value_type, std::is_floating_point_v<Value_type> > jau::math::Quaternion< Value_type, >::Vec3

Definition at line 72 of file quaternion.hpp.

Constructor & Destructor Documentation

◆ Quaternion() [1/4]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr jau::math::Quaternion< Value_type, >::Quaternion ( )
inlineconstexprnoexcept

Definition at line 92 of file quaternion.hpp.

◆ Quaternion() [2/4]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr jau::math::Quaternion< Value_type, >::Quaternion ( const value_type  x,
const value_type  y,
const value_type  z,
const value_type  w 
)
inlineconstexprnoexcept

Definition at line 95 of file quaternion.hpp.

◆ Quaternion() [3/4]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr jau::math::Quaternion< Value_type, >::Quaternion ( const Quaternion< Value_type, > &  o)
constexprdefaultnoexcept

◆ Quaternion() [4/4]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr jau::math::Quaternion< Value_type, >::Quaternion ( Quaternion< Value_type, > &&  o)
constexprdefaultnoexcept

Member Function Documentation

◆ operator=() [1/2]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr Quaternion & jau::math::Quaternion< Value_type, >::operator= ( const Quaternion< Value_type, > &  )
constexprdefaultnoexcept

◆ operator=() [2/2]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr Quaternion & jau::math::Quaternion< Value_type, >::operator= ( Quaternion< Value_type, > &&  )
constexprdefaultnoexcept

◆ magnitudeSquared()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr value_type jau::math::Quaternion< Value_type, >::magnitudeSquared ( ) const
inlineconstexprnoexcept

See magnitude() for special handling of epsilon, which is not applied here.

Returns
the squared magnitude of this quaternion.

Definition at line 108 of file quaternion.hpp.

◆ magnitude()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr_cxx26 value_type jau::math::Quaternion< Value_type, >::magnitude ( ) const
inlinenoexcept

Return the magnitude of this quaternion, i.e.

sqrt(magnitudeSquared())

A magnitude of zero shall equal identity, as performed by normalize().

Implementation Details:

Definition at line 126 of file quaternion.hpp.

Here is the caller graph for this function:

◆ w()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr value_type jau::math::Quaternion< Value_type, >::w ( ) const
inlineconstexprnoexcept

Definition at line 137 of file quaternion.hpp.

◆ setW()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr void jau::math::Quaternion< Value_type, >::setW ( value_type  w)
inlineconstexprnoexcept

Definition at line 139 of file quaternion.hpp.

◆ x()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr value_type jau::math::Quaternion< Value_type, >::x ( ) const
inlineconstexprnoexcept

Definition at line 141 of file quaternion.hpp.

◆ setX()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr void jau::math::Quaternion< Value_type, >::setX ( value_type  x)
inlineconstexprnoexcept

Definition at line 143 of file quaternion.hpp.

◆ y()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr value_type jau::math::Quaternion< Value_type, >::y ( ) const
inlineconstexprnoexcept

Definition at line 145 of file quaternion.hpp.

◆ setY()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr void jau::math::Quaternion< Value_type, >::setY ( value_type  y)
inlineconstexprnoexcept

Definition at line 147 of file quaternion.hpp.

◆ z()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr value_type jau::math::Quaternion< Value_type, >::z ( ) const
inlineconstexprnoexcept

Definition at line 149 of file quaternion.hpp.

◆ setZ()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr void jau::math::Quaternion< Value_type, >::setZ ( value_type  z)
inlineconstexprnoexcept

Definition at line 151 of file quaternion.hpp.

◆ dot() [1/2]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr value_type jau::math::Quaternion< Value_type, >::dot ( value_type  x,
value_type  y,
value_type  z,
value_type  w 
) const
inlineconstexprnoexcept

Returns the dot product of this quaternion with the given x,y,z and m_w components.

Definition at line 156 of file quaternion.hpp.

Here is the caller graph for this function:

◆ dot() [2/2]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr value_type jau::math::Quaternion< Value_type, >::dot ( const Quaternion< Value_type, > &  quat) const
inlineconstexprnoexcept

Returns the dot product of this quaternion with the given quaternion.

Definition at line 163 of file quaternion.hpp.

◆ isIdentity()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr bool jau::math::Quaternion< Value_type, >::isIdentity ( ) const
inlineconstexprnoexcept

Returns true if this quaternion has identity.

Implementation uses epsilon to compare W against 1f and X, Y and Z against zero.

Definition at line 176 of file quaternion.hpp.

◆ setIdentity()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr Quaternion & jau::math::Quaternion< Value_type, >::setIdentity ( )
inlineconstexprnoexcept

Definition at line 185 of file quaternion.hpp.

Here is the caller graph for this function:

◆ normalize()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr Quaternion & jau::math::Quaternion< Value_type, >::normalize ( )
inlineconstexprnoexcept

Normalize a quaternion required if to be used as a rotational quaternion.

Implementation Details:

Returns
this quaternion for chaining.

Definition at line 200 of file quaternion.hpp.

Here is the caller graph for this function:

◆ conjugate()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr Quaternion & jau::math::Quaternion< Value_type, >::conjugate ( )
inlineconstexprnoexcept

Conjugates this quaternion [-x, -y, -z, w].

Returns
this quaternion for chaining.
See also
Matrix-FAQ Q49

Definition at line 219 of file quaternion.hpp.

Here is the caller graph for this function:

◆ invert()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr Quaternion & jau::math::Quaternion< Value_type, >::invert ( )
inlineconstexprnoexcept

Invert the quaternion If rotational, will produce a the inverse rotation.

Implementation Details:

Returns
this quaternion for chaining.
See also
Matrix-FAQ Q50

Definition at line 237 of file quaternion.hpp.

Here is the caller graph for this function:

◆ set()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr Quaternion & jau::math::Quaternion< Value_type, >::set ( const value_type  x,
const value_type  y,
const value_type  z,
const value_type  w 
)
inlineconstexprnoexcept

Set all values of this quaternion using the given components.

Returns
this quaternion for chaining.

Definition at line 255 of file quaternion.hpp.

Here is the caller graph for this function:

◆ operator+=()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr Quaternion & jau::math::Quaternion< Value_type, >::operator+= ( const Quaternion< Value_type, > &  rhs)
inlineconstexprnoexcept

Add a quaternion: this = this + rhs, returns this.

Parameters
qquaternion
Returns
this quaternion for chaining.
See also
euclideanspace.com-QuaternionAdd

Definition at line 270 of file quaternion.hpp.

◆ operator-=()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr Quaternion & jau::math::Quaternion< Value_type, >::operator-= ( const Quaternion< Value_type, > &  rhs)
inlineconstexprnoexcept

Subtract a quaternion: this = this - rhs, returns this.

Parameters
qquaternion
Returns
this quaternion for chaining.
See also
euclideanspace.com-QuaternionAdd

Definition at line 285 of file quaternion.hpp.

◆ operator*=() [1/2]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr Quaternion & jau::math::Quaternion< Value_type, >::operator*= ( const Quaternion< Value_type, > &  rhs)
inlineconstexprnoexcept

Multiply this quaternion: this = this * rhs, returns this.

Parameters
qa quaternion to multiply with
Returns
this quaternion for chaining.
See also
Matrix-FAQ Q53
euclideanspace.com-QuaternionMul

Definition at line 301 of file quaternion.hpp.

◆ operator*=() [2/2]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr Quaternion & jau::math::Quaternion< Value_type, >::operator*= ( const value_type  rhs)
inlineconstexprnoexcept

Scale this quaternion by a scalar: this = this * rhs, returns this.

Parameters
na value_type constant
Returns
this quaternion for chaining.
See also
euclideanspace.com-QuaternionScale

Definition at line 315 of file quaternion.hpp.

◆ rotateByAngleNormalAxis() [1/2]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr_cxx26 Quaternion & jau::math::Quaternion< Value_type, >::rotateByAngleNormalAxis ( const value_type  angle,
const value_type  axisX,
const value_type  axisY,
const value_type  axisZ 
)
inlinenoexcept

Rotate this quaternion by the given angle and axis.

The axis must be a normalized vector.

A rotational quaternion is made from the given angle and axis.

Parameters
anglein radians
axisXx-coord of rotation axis
axisYy-coord of rotation axis
axisZm_z-coord of rotation axis
Returns
this quaternion for chaining.

Definition at line 338 of file quaternion.hpp.

Here is the caller graph for this function:

◆ rotateByAngleNormalAxis() [2/2]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr_cxx26 Quaternion & jau::math::Quaternion< Value_type, >::rotateByAngleNormalAxis ( const value_type  angle,
const Vec3 axis 
)
inlinenoexcept

Rotate this quaternion by the given angle and axis.

The axis must be a normalized vector.

A rotational quaternion is made from the given angle and axis.

Parameters
anglein radians
axisVec3 coord of rotation axis
Returns
this quaternion for chaining.

Definition at line 368 of file quaternion.hpp.

◆ rotateByAngleX() [1/2]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr_cxx26 Quaternion & jau::math::Quaternion< Value_type, >::rotateByAngleX ( const value_type  angle)
inlinenoexcept

Rotate this quaternion around X axis with the given angle in radians.

Parameters
anglein radians
Returns
this quaternion for chaining.

Definition at line 378 of file quaternion.hpp.

Here is the caller graph for this function:

◆ rotateByAngleX() [2/2]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr Quaternion & jau::math::Quaternion< Value_type, >::rotateByAngleX ( const value_type  sin,
const value_type  cos 
)
inlineconstexprnoexcept

Rotate this quaternion around X axis with the given angle's sin + cos values.

Definition at line 383 of file quaternion.hpp.

◆ rotateByAngleY() [1/2]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr_cxx26 Quaternion & jau::math::Quaternion< Value_type, >::rotateByAngleY ( value_type  angle)
inlinenoexcept

Rotate this quaternion around Y axis with the given angle in radians.

Parameters
anglein radians
Returns
this quaternion for chaining.

Definition at line 396 of file quaternion.hpp.

Here is the caller graph for this function:

◆ rotateByAngleY() [2/2]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr Quaternion & jau::math::Quaternion< Value_type, >::rotateByAngleY ( const value_type  sin,
const value_type  cos 
)
inlineconstexprnoexcept

Rotate this quaternion around Y axis with the given angle's sin + cos values.

Definition at line 401 of file quaternion.hpp.

◆ rotateByAngleZ() [1/2]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr_cxx26 Quaternion & jau::math::Quaternion< Value_type, >::rotateByAngleZ ( value_type  angle)
inlinenoexcept

Rotate this quaternion around Z axis with the given angle in radians.

Parameters
anglein radians
Returns
this quaternion for chaining.

Definition at line 414 of file quaternion.hpp.

Here is the caller graph for this function:

◆ rotateByAngleZ() [2/2]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr Quaternion & jau::math::Quaternion< Value_type, >::rotateByAngleZ ( const value_type  sin,
const value_type  cos 
)
inlineconstexprnoexcept

Rotate this quaternion around Y axis with the given angle's sin + cos values.

Definition at line 419 of file quaternion.hpp.

◆ rotateByEuler() [1/2]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
Quaternion & jau::math::Quaternion< Value_type, >::rotateByEuler ( const Vec3 angradXYZ)
inlinenoexcept

Rotates this quaternion from the given Euler rotation array angradXYZ in radians.

The angradXYZ array is laid out in natural order:

  • x - bank
  • y - heading
  • z - attitude

For details see rotateByEuler(value_type, value_type, value_type).

Parameters
angradXYZeuler angle array in radians
Returns
this quaternion for chaining.
See also
rotateByEuler(value_type, value_type, value_type)

Definition at line 441 of file quaternion.hpp.

◆ rotateByEuler() [2/2]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr_cxx26 Quaternion & jau::math::Quaternion< Value_type, >::rotateByEuler ( const value_type  bankX,
const value_type  headingY,
const value_type  attitudeZ 
)
inlinenoexcept

Rotates this quaternion from the given Euler rotation angles in radians.

The rotations are applied in the given order and using chained rotation per axis:

Implementation Details:

Parameters
bankXthe Euler pitch angle in radians. (rotation about the X axis)
headingYthe Euler yaw angle in radians. (rotation about the Y axis)
attitudeZthe Euler roll angle in radians. (rotation about the Z axis)
Returns
this quaternion for chaining.
See also
rotateByAngleY(value_type)
rotateByAngleZ(value_type)
rotateByAngleX(value_type)
setFromEuler(value_type, value_type, value_type)

Definition at line 471 of file quaternion.hpp.

◆ rotateVector() [1/2]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
Vec3 jau::math::Quaternion< Value_type, >::rotateVector ( const Vec3 in)
inlinenoexcept

Definition at line 488 of file quaternion.hpp.

Here is the caller graph for this function:

◆ rotateVector() [2/2]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
Vec3 & jau::math::Quaternion< Value_type, >::rotateVector ( const Vec3 in,
Vec3 out 
)
inlinenoexcept

Definition at line 501 of file quaternion.hpp.

◆ setSlerp()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr_cxx26 Quaternion & jau::math::Quaternion< Value_type, >::setSlerp ( const Quaternion< Value_type, > &  a,
const Quaternion< Value_type, > &  b,
const value_type  changeAmnt 
)
inlinenoexcept

Set this quaternion to a spherical linear interpolation between the given start and end quaternions by the given change amount.

Note: Method does not normalize this quaternion!

Parameters
astart quaternion
bend quaternion
changeAmntvalue_type between 0 and 1 representing interpolation.
Returns
this quaternion for chaining.
See also
euclideanspace.com-QuaternionSlerp

Definition at line 548 of file quaternion.hpp.

Here is the caller graph for this function:

◆ setLookAt()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
Quaternion & jau::math::Quaternion< Value_type, >::setLookAt ( const Vec3 directionIn,
const Vec3 upIn,
Vec3 xAxisOut,
Vec3 yAxisOut,
Vec3 zAxisOut 
)
inlinenoexcept

Set this quaternion to equal the rotation required to point the z-axis at direction and the y-axis to up.

Implementation generates a 3x3 matrix and is equal with ProjectFloat's lookAt(..).

Implementation Details:

Parameters
directionInwhere to look at
upIna vector indicating the local up direction.
xAxisOutvector storing the orthogonal x-axis of the coordinate system.
yAxisOutvector storing the orthogonal y-axis of the coordinate system.
zAxisOutvector storing the orthogonal m_z-axis of the coordinate system.
Returns
this quaternion for chaining.
See also
euclideanspace.com-LookUp

Definition at line 627 of file quaternion.hpp.

Here is the caller graph for this function:

◆ setFromVectors()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr_cxx26 Quaternion & jau::math::Quaternion< Value_type, >::setFromVectors ( const Vec3 v1,
const Vec3 v2 
)
inlinenoexcept

Initialize this quaternion from two vectors.

  q = (s,v) = (v1•v2 , v1 × v2),
    angle = angle(v1, v2) = v1•v2
     axis = normal(v1 x v2)

<p<blockquote>‍

Implementation Details:

  • set_identity() if square vector-length is jau::is_zero2f(value_type, value_type) using epsilon
Parameters
v1not normalized
v2not normalized
Returns
this quaternion for chaining.

Definition at line 676 of file quaternion.hpp.

Here is the caller graph for this function:

◆ setFromNormalVectors()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr_cxx26 Quaternion & jau::math::Quaternion< Value_type, >::setFromNormalVectors ( const Vec3 v1,
const Vec3 v2 
)
inlinenoexcept

Initialize this quaternion from two normalized vectors.

  q = (s,v) = (v1•v2 , v1 × v2),
    angle = angle(v1, v2) = v1•v2
     axis = v1 x v2

<p<blockquote>‍

Implementation Details:

Parameters
v1normalized
v2normalized
Returns
this quaternion for chaining.

Definition at line 730 of file quaternion.hpp.

Here is the caller graph for this function:

◆ setFromAngleAxis()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
Quaternion & jau::math::Quaternion< Value_type, >::setFromAngleAxis ( const value_type  angle,
const Vec3 vector 
)
inlinenoexcept

Definition at line 782 of file quaternion.hpp.

Here is the caller graph for this function:

◆ setFromAngleNormalAxis()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr_cxx26 Quaternion & jau::math::Quaternion< Value_type, >::setFromAngleNormalAxis ( const value_type  angle,
const Vec3 vector 
)
inlinenoexcept

Definition at line 801 of file quaternion.hpp.

Here is the caller graph for this function:

◆ toAngleAxis()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr_cxx26 value_type jau::math::Quaternion< Value_type, >::toAngleAxis ( Vec3 axis) const
inlinenoexcept

Transform the rotational quaternion to axis based rotation angles.

Parameters
axisstorage for computed axis
Returns
the rotation angle in radians
See also
#setFromAngleAxis(value_type, Vec3, Vec3)

Definition at line 822 of file quaternion.hpp.

Here is the caller graph for this function:

◆ setFromEuler() [1/2]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr_cxx26 Quaternion & jau::math::Quaternion< Value_type, >::setFromEuler ( const Vec3 angradXYZ)
inlinenoexcept

Initializes this quaternion from the given Euler rotation array angradXYZ in radians.

The angradXYZ vector is laid out in natural order:

  • x - bank
  • y - heading
  • z - attitude

For details see setFromEuler(value_type, value_type, value_type).

Parameters
angradXYZeuler angle vector in radians holding x-bank, m_y-heading and m_z-attitude
Returns
this quaternion for chaining.
See also
setFromEuler(value_type, value_type, value_type)

Definition at line 853 of file quaternion.hpp.

Here is the caller graph for this function:

◆ setFromEuler() [2/2]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr_cxx26 Quaternion & jau::math::Quaternion< Value_type, >::setFromEuler ( const value_type  bankX,
const value_type  headingY,
const value_type  attitudeZ 
)
inlinenoexcept

Initializes this quaternion from the given Euler rotation angles in radians.

The rotations are applied in the given order:

  • y - heading
  • z - attitude
  • x - bank

Implementation Details:

Parameters
bankXthe Euler pitch angle in radians. (rotation about the X axis)
headingYthe Euler yaw angle in radians. (rotation about the Y axis)
attitudeZthe Euler roll angle in radians. (rotation about the Z axis)
Returns
this quaternion for chaining.
See also
Matrix-FAQ Q60
Gems
euclideanspace.com-eulerToQuaternion
#toEuler(Vec3)

Definition at line 884 of file quaternion.hpp.

◆ toEuler()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr_cxx26 Vec3 jau::math::Quaternion< Value_type, >::toEuler ( )
inlinenoexcept

Transform this quaternion to Euler rotation angles in radians (pitchX, yawY and rollZ).

The result array is laid out in natural order:

  • x - bank
  • y - heading
  • z - attitude
Returns
new Vec3 euler angle result vector filled with x-bank, y-heading and m_z-attitude
See also
euclideanspace.com-quaternionToEuler
setFromEuler(value_type, value_type, value_type)

Definition at line 927 of file quaternion.hpp.

Here is the caller graph for this function:

◆ setFromMat() [1/2]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr Quaternion & jau::math::Quaternion< Value_type, >::setFromMat ( const value_type  m00,
const value_type  m01,
const value_type  m02,
const value_type  m10,
const value_type  m11,
const value_type  m12,
const value_type  m20,
const value_type  m21,
const value_type  m22 
)
inlineconstexprnoexcept

Compute the quaternion from a 3x3 column rotation matrix.

See Graphics Gems Code,
MatrixTrace.

Buggy Matrix-FAQ Q55

Returns
this quaternion for chaining.
See also
#setFromMatrix(Matrix4f)

Definition at line 963 of file quaternion.hpp.

Here is the caller graph for this function:

◆ setFromMat() [2/2]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr Quaternion & jau::math::Quaternion< Value_type, >::setFromMat ( const Mat4f m)
inlineconstexprnoexcept

Compute the quaternion from a 3x3 column rotation matrix from mat4f instance.

See Graphics Gems Code,
MatrixTrace.

Buggy Matrix-FAQ Q55

Returns
this quaternion for chaining.
See also
Matrix4f::getRotation(Quaternion)
#setFromMatrix(value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type)

Definition at line 1014 of file quaternion.hpp.

◆ setFromAxes()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr Quaternion & jau::math::Quaternion< Value_type, >::setFromAxes ( const Vec3 xAxis,
const Vec3 yAxis,
const Vec3 zAxis 
)
inlineconstexprnoexcept

Initializes this quaternion to represent a rotation formed by the given three orthogonal axes.

No validation whether the axes are orthogonal is performed.

Parameters
xAxisvector representing the orthogonal x-axis of the coordinate system.
yAxisvector representing the orthogonal y-axis of the coordinate system.
zAxisvector representing the orthogonal m_z-axis of the coordinate system.
Returns
this quaternion for chaining.

Definition at line 1029 of file quaternion.hpp.

Here is the caller graph for this function:

◆ toMatrix() [1/2]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr Mat4f jau::math::Quaternion< Value_type, >::toMatrix ( ) const
inlineconstexprnoexcept

Transform this quaternion to a normalized 4x4 column matrix representing the rotation.

Implementation Details:

Returns
resulting normalized column matrix 4x4
See also
Matrix-FAQ Q54
#setFromMatrix(value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type)
Matrix4f::setToRotation(Quaternion)

Definition at line 1049 of file quaternion.hpp.

Here is the caller graph for this function:

◆ toMatrix() [2/2]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr Mat4f & jau::math::Quaternion< Value_type, >::toMatrix ( Mat4f m) const
inlineconstexprnoexcept

Transform this quaternion to a normalized 4x4 column matrix representing the rotation, see toMatrix().

Parameters
outstore for the resulting normalized column matrix 4x4
Returns
the given matrix store

Definition at line 1060 of file quaternion.hpp.

◆ toAxes() [1/2]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr void jau::math::Quaternion< Value_type, >::toAxes ( Vec3 xAxis,
Vec3 yAxis,
Vec3 zAxis,
Matrix4< value_type > &  tmp 
) const
inlineconstexprnoexcept

Extracts this quaternion's orthogonal rotation axes.

Parameters
xAxisvector representing the orthogonal x-axis of the coordinate system.
yAxisvector representing the orthogonal y-axis of the coordinate system.
zAxisvector representing the orthogonal m_z-axis of the coordinate system.
tmptemporary Matrix4 used for toMatrix()

Definition at line 1121 of file quaternion.hpp.

Here is the caller graph for this function:

◆ toAxes() [2/2]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr void jau::math::Quaternion< Value_type, >::toAxes ( Vec3 xAxis,
Vec3 yAxis,
Vec3 zAxis 
) const
inlineconstexprnoexcept

Extracts this quaternion's orthogonal rotation axes.

Parameters
xAxisvector representing the orthogonal x-axis of the coordinate system.
yAxisvector representing the orthogonal y-axis of the coordinate system.
zAxisvector representing the orthogonal m_z-axis of the coordinate system.

Definition at line 1135 of file quaternion.hpp.

◆ operator==()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr bool jau::math::Quaternion< Value_type, >::operator== ( const Quaternion< Value_type, > &  o) const
inlineconstexprnoexcept
Parameters
othe object to compare for equality
Returns
true if this quaternion and the provided quaternion have roughly the same x, m_y, m_z and m_w values.

Definition at line 1148 of file quaternion.hpp.

◆ toString()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
std::string jau::math::Quaternion< Value_type, >::toString ( ) const
inlinenoexcept

Definition at line 1158 of file quaternion.hpp.

Member Data Documentation

◆ zero

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr const value_type jau::math::Quaternion< Value_type, >::zero = value_type(0)
staticconstexpr

Definition at line 74 of file quaternion.hpp.

◆ one

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr const value_type jau::math::Quaternion< Value_type, >::one = value_type(1)
staticconstexpr

Definition at line 75 of file quaternion.hpp.

◆ two

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr const value_type jau::math::Quaternion< Value_type, >::two = value_type(2)
staticconstexpr

Definition at line 76 of file quaternion.hpp.

◆ half

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr const value_type jau::math::Quaternion< Value_type, >::half = one/two
staticconstexpr

Definition at line 77 of file quaternion.hpp.

◆ allowed_deviation

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr const value_type jau::math::Quaternion< Value_type, >::allowed_deviation = value_type(8.4) * std::numeric_limits<value_type>::epsilon()
staticconstexpr

Quaternion Epsilon, used with equals method to determine if two Quaternions are close enough to be considered equal.

Using {@value}, which is ~8.4 times std::numeric_limits<value_type>::epsilon().

Definition at line 85 of file quaternion.hpp.


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