Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
|
Quaternion implementation supporting Gimbal-Lock free rotations. More...
#include <quaternion.hpp>
Public Types | |
typedef const value_type * | const_iterator |
typedef const value_type * | const_pointer |
typedef const value_type & | const_reference |
typedef value_type * | iterator |
typedef value_type * | pointer |
typedef value_type & | reference |
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 Quaternion & | conjugate () 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 Quaternion & | invert () 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 Quaternion & | normalize () noexcept |
Normalize a quaternion required if to be used as a rotational quaternion. More... | |
constexpr Quaternion & | operator*= (const Quaternion &rhs) noexcept |
Multiply this quaternion: this = this * rhs, returns this. More... | |
constexpr Quaternion & | operator*= (const value_type rhs) noexcept |
Scale this quaternion by a scalar: this = this * rhs, returns this. More... | |
constexpr Quaternion & | operator+= (const Quaternion &rhs) noexcept |
Add a quaternion: this = this + rhs, returns this. More... | |
constexpr Quaternion & | operator-= (const Quaternion &rhs) noexcept |
Subtract a quaternion: this = this - rhs, returns this. More... | |
constexpr Quaternion & | operator= (const Quaternion &) noexcept=default |
constexpr Quaternion & | operator= (Quaternion &&) noexcept=default |
constexpr bool | operator== (const Quaternion &o) const noexcept |
constexpr_cxx26 Quaternion & | rotateByAngleNormalAxis (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 Quaternion & | rotateByAngleNormalAxis (const value_type angle, const Vec3 &axis) noexcept |
Rotate this quaternion by the given angle and axis. More... | |
constexpr_cxx26 Quaternion & | rotateByAngleX (const value_type angle) noexcept |
Rotate this quaternion around X axis with the given angle in radians. More... | |
constexpr Quaternion & | rotateByAngleX (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 Quaternion & | rotateByAngleY (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 Quaternion & | rotateByAngleY (value_type angle) noexcept |
Rotate this quaternion around Y axis with the given angle in radians. More... | |
constexpr Quaternion & | rotateByAngleZ (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 Quaternion & | rotateByAngleZ (value_type angle) noexcept |
Rotate this quaternion around Z axis with the given angle in radians. More... | |
constexpr_cxx26 Quaternion & | rotateByEuler (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... | |
Quaternion & | rotateByEuler (const Vec3 &angradXYZ) noexcept |
Rotates this quaternion from the given Euler rotation array angradXYZ in radians. More... | |
Vec3 | rotateVector (const Vec3 &in) noexcept |
Vec3 & | rotateVector (const Vec3 &in, Vec3 &out) noexcept |
constexpr Quaternion & | set (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... | |
Quaternion & | setFromAngleAxis (const value_type angle, const Vec3 &vector) noexcept |
constexpr_cxx26 Quaternion & | setFromAngleNormalAxis (const value_type angle, const Vec3 &vector) noexcept |
constexpr Quaternion & | setFromAxes (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 Quaternion & | setFromEuler (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 Quaternion & | setFromEuler (const Vec3 &angradXYZ) noexcept |
Initializes this quaternion from the given Euler rotation array angradXYZ in radians. More... | |
constexpr Quaternion & | setFromMat (const Mat4f &m) noexcept |
Compute the quaternion from a 3x3 column rotation matrix from mat4f instance. More... | |
constexpr Quaternion & | 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) noexcept |
Compute the quaternion from a 3x3 column rotation matrix. More... | |
constexpr_cxx26 Quaternion & | setFromNormalVectors (const Vec3 &v1, const Vec3 &v2) noexcept |
Initialize this quaternion from two normalized vectors. More... | |
constexpr_cxx26 Quaternion & | setFromVectors (const Vec3 &v1, const Vec3 &v2) noexcept |
Initialize this quaternion from two vectors. More... | |
constexpr Quaternion & | setIdentity () noexcept |
Quaternion & | setLookAt (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 Quaternion & | setSlerp (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 Mat4f & | toMatrix (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) |
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.
typedef Value_type jau::math::Quaternion< Value_type, >::value_type |
Definition at line 64 of file quaternion.hpp.
typedef value_type* jau::math::Quaternion< Value_type, >::pointer |
Definition at line 65 of file quaternion.hpp.
typedef const value_type* jau::math::Quaternion< Value_type, >::const_pointer |
Definition at line 66 of file quaternion.hpp.
typedef value_type& jau::math::Quaternion< Value_type, >::reference |
Definition at line 67 of file quaternion.hpp.
typedef const value_type& jau::math::Quaternion< Value_type, >::const_reference |
Definition at line 68 of file quaternion.hpp.
typedef value_type* jau::math::Quaternion< Value_type, >::iterator |
Definition at line 69 of file quaternion.hpp.
typedef const value_type* jau::math::Quaternion< Value_type, >::const_iterator |
Definition at line 70 of file quaternion.hpp.
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.
|
inlineconstexprnoexcept |
Definition at line 92 of file quaternion.hpp.
|
inlineconstexprnoexcept |
Definition at line 95 of file quaternion.hpp.
|
constexprdefaultnoexcept |
|
constexprdefaultnoexcept |
|
constexprdefaultnoexcept |
|
constexprdefaultnoexcept |
|
inlineconstexprnoexcept |
See magnitude()
for special handling of epsilon
, which is not applied here.
Definition at line 108 of file quaternion.hpp.
|
inlinenoexcept |
Return the magnitude of this quaternion, i.e.
sqrt(magnitudeSquared()
)
A magnitude of zero shall equal identity
, as performed by normalize()
.
Implementation Details:
magnitudeSquared()
is is zero
using epsilon
magnitudeSquared()
is equals 1f
using epsilon
Definition at line 126 of file quaternion.hpp.
|
inlineconstexprnoexcept |
Definition at line 137 of file quaternion.hpp.
|
inlineconstexprnoexcept |
Definition at line 139 of file quaternion.hpp.
|
inlineconstexprnoexcept |
Definition at line 141 of file quaternion.hpp.
|
inlineconstexprnoexcept |
Definition at line 143 of file quaternion.hpp.
|
inlineconstexprnoexcept |
Definition at line 145 of file quaternion.hpp.
|
inlineconstexprnoexcept |
Definition at line 147 of file quaternion.hpp.
|
inlineconstexprnoexcept |
Definition at line 149 of file quaternion.hpp.
|
inlineconstexprnoexcept |
Definition at line 151 of file quaternion.hpp.
|
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.
|
inlineconstexprnoexcept |
Returns the dot product of this quaternion with the given quaternion.
Definition at line 163 of file quaternion.hpp.
|
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.
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
Normalize a quaternion required if to be used as a rotational quaternion.
Implementation Details:
setIdentity()
if magnitude()
is is zero
using epsilon Definition at line 200 of file quaternion.hpp.
|
inlineconstexprnoexcept |
Conjugates this quaternion [-x, -y, -z, w]
.
Definition at line 219 of file quaternion.hpp.
|
inlineconstexprnoexcept |
Invert the quaternion If rotational, will produce a the inverse rotation.
Implementation Details:
conjugates
if magnitudeSquared()
is is equals 1f
using epsilon
Definition at line 237 of file quaternion.hpp.
|
inlineconstexprnoexcept |
Set all values of this quaternion using the given components.
Definition at line 255 of file quaternion.hpp.
|
inlineconstexprnoexcept |
Add a quaternion: this = this + rhs, returns this.
q | quaternion |
Definition at line 270 of file quaternion.hpp.
|
inlineconstexprnoexcept |
Subtract a quaternion: this = this - rhs, returns this.
q | quaternion |
Definition at line 285 of file quaternion.hpp.
|
inlineconstexprnoexcept |
Multiply this quaternion: this = this * rhs, returns this.
q | a quaternion to multiply with |
Definition at line 301 of file quaternion.hpp.
|
inlineconstexprnoexcept |
Scale this quaternion by a scalar: this = this * rhs, returns this.
n | a value_type constant |
Definition at line 315 of file quaternion.hpp.
|
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.
angle | in radians |
axisX | x-coord of rotation axis |
axisY | y-coord of rotation axis |
axisZ | m_z-coord of rotation axis |
Definition at line 338 of file quaternion.hpp.
|
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.
angle | in radians |
axis | Vec3 coord of rotation axis |
Definition at line 368 of file quaternion.hpp.
|
inlinenoexcept |
Rotate this quaternion around X axis with the given angle in radians.
angle | in radians |
Definition at line 378 of file quaternion.hpp.
|
inlineconstexprnoexcept |
Rotate this quaternion around X axis with the given angle's sin + cos values.
Definition at line 383 of file quaternion.hpp.
|
inlinenoexcept |
Rotate this quaternion around Y axis with the given angle in radians.
angle | in radians |
Definition at line 396 of file quaternion.hpp.
|
inlineconstexprnoexcept |
Rotate this quaternion around Y axis with the given angle's sin + cos values.
Definition at line 401 of file quaternion.hpp.
|
inlinenoexcept |
Rotate this quaternion around Z axis with the given angle in radians.
angle | in radians |
Definition at line 414 of file quaternion.hpp.
|
inlineconstexprnoexcept |
Rotate this quaternion around Y axis with the given angle's sin + cos values.
Definition at line 419 of file quaternion.hpp.
|
inlinenoexcept |
Rotates this quaternion from the given Euler rotation array angradXYZ
in radians.
The angradXYZ
array is laid out in natural order:
For details see rotateByEuler(value_type, value_type, value_type)
.
angradXYZ | euler angle array in radians |
Definition at line 441 of file quaternion.hpp.
|
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:
rotateByAngleY(value_type)
rotateByAngleZ(value_type)
rotateByAngleX(value_type)
Implementation Details:
is zero
using epsilon
normalize()
ed bankX | the Euler pitch angle in radians. (rotation about the X axis) |
headingY | the Euler yaw angle in radians. (rotation about the Y axis) |
attitudeZ | the Euler roll angle in radians. (rotation about the Z axis) |
Definition at line 471 of file quaternion.hpp.
|
inlinenoexcept |
|
inlinenoexcept |
Definition at line 501 of file quaternion.hpp.
|
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!
a | start quaternion |
b | end quaternion |
changeAmnt | value_type between 0 and 1 representing interpolation. |
Definition at line 548 of file quaternion.hpp.
|
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:
normalize()
ed directionIn | where to look at |
upIn | a vector indicating the local up direction. |
xAxisOut | vector storing the orthogonal x-axis of the coordinate system. |
yAxisOut | vector storing the orthogonal y-axis of the coordinate system. |
zAxisOut | vector storing the orthogonal m_z-axis of the coordinate system. |
Definition at line 627 of file quaternion.hpp.
|
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:
v1 | not normalized |
v2 | not normalized |
Definition at line 676 of file quaternion.hpp.
|
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:
setIdentity()
if square vector-length is is zero
using epsilon
v1 | normalized |
v2 | normalized |
Definition at line 730 of file quaternion.hpp.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
Transform the rotational quaternion to axis based rotation angles.
axis | storage for computed axis |
Definition at line 822 of file quaternion.hpp.
|
inlinenoexcept |
Initializes this quaternion from the given Euler rotation array angradXYZ
in radians.
The angradXYZ
vector is laid out in natural order:
For details see setFromEuler(value_type, value_type, value_type)
.
angradXYZ | euler angle vector in radians holding x-bank, m_y-heading and m_z-attitude |
Definition at line 853 of file quaternion.hpp.
|
inlinenoexcept |
Initializes this quaternion from the given Euler rotation angles in radians.
The rotations are applied in the given order:
Implementation Details:
setIdentity()
if all angles are is zero
using epsilon
normalize()
ed bankX | the Euler pitch angle in radians. (rotation about the X axis) |
headingY | the Euler yaw angle in radians. (rotation about the Y axis) |
attitudeZ | the Euler roll angle in radians. (rotation about the Z axis) |
Definition at line 884 of file quaternion.hpp.
|
inlinenoexcept |
Transform this quaternion to Euler rotation angles in radians (pitchX, yawY and rollZ).
The result
array is laid out in natural order:
Definition at line 927 of file quaternion.hpp.
|
inlineconstexprnoexcept |
Compute the quaternion from a 3x3 column rotation matrix.
See Graphics Gems Code,
MatrixTrace.
Buggy Matrix-FAQ Q55
Definition at line 963 of file quaternion.hpp.
|
inlineconstexprnoexcept |
Compute the quaternion from a 3x3 column rotation matrix from mat4f instance.
See Graphics Gems Code,
MatrixTrace.
Buggy Matrix-FAQ Q55
Definition at line 1014 of file quaternion.hpp.
|
inlineconstexprnoexcept |
Initializes this quaternion to represent a rotation formed by the given three orthogonal axes.
No validation whether the axes are orthogonal is performed.
xAxis | vector representing the orthogonal x-axis of the coordinate system. |
yAxis | vector representing the orthogonal y-axis of the coordinate system. |
zAxis | vector representing the orthogonal m_z-axis of the coordinate system. |
Definition at line 1029 of file quaternion.hpp.
|
inlineconstexprnoexcept |
Transform this quaternion to a normalized 4x4 column matrix representing the rotation.
Implementation Details:
magnitudeSquared()
is is zero
using epsilon
Definition at line 1049 of file quaternion.hpp.
|
inlineconstexprnoexcept |
Transform this quaternion to a normalized 4x4 column matrix representing the rotation, see toMatrix().
out | store for the resulting normalized column matrix 4x4 |
Definition at line 1060 of file quaternion.hpp.
|
inlineconstexprnoexcept |
Extracts this quaternion's orthogonal rotation axes.
xAxis | vector representing the orthogonal x-axis of the coordinate system. |
yAxis | vector representing the orthogonal y-axis of the coordinate system. |
zAxis | vector representing the orthogonal m_z-axis of the coordinate system. |
tmp | temporary Matrix4 used for toMatrix() |
Definition at line 1121 of file quaternion.hpp.
|
inlineconstexprnoexcept |
Extracts this quaternion's orthogonal rotation axes.
xAxis | vector representing the orthogonal x-axis of the coordinate system. |
yAxis | vector representing the orthogonal y-axis of the coordinate system. |
zAxis | vector representing the orthogonal m_z-axis of the coordinate system. |
Definition at line 1135 of file quaternion.hpp.
|
inlineconstexprnoexcept |
o | the object to compare for equality |
Definition at line 1148 of file quaternion.hpp.
|
inlinenoexcept |
Definition at line 1158 of file quaternion.hpp.
|
staticconstexpr |
Definition at line 74 of file quaternion.hpp.
|
staticconstexpr |
Definition at line 75 of file quaternion.hpp.
|
staticconstexpr |
Definition at line 76 of file quaternion.hpp.
|
staticconstexpr |
Definition at line 77 of file quaternion.hpp.
|
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.