|
AGX Dynamics 2.41.2.0
|
The object holding quaternions and providing operations on these. More...
#include <QuatTemplate.h>
Public Types | |
| typedef T | Type |
Public Member Functions | |
| QuatT () | |
| Default constructor. Create a Quaternion with an identity rotation. | |
| QuatT (const AffineMatrix4x4T< T > &matrix) | |
| Create a Quaternion based on the rotation part in the specified Affine 4x4 transformation matrix. | |
| QuatT (const EulerAngles &euler) | |
Create a Quaternion based on the rotation from euler specified as a EulerAngle. | |
| QuatT (const QuatT< T > ©)=default | |
| Copy constructor. | |
| template<typename T2 > | |
| QuatT (const QuatT< T2 > ©) | |
| Copy constructor for other types. | |
| QuatT (const Vec3T< T > &from, const Vec3T< T > &to) | |
Create a Quaternion which maps the rotation from vector from to the vector to. | |
| QuatT (const Vec4T< T > &v) | |
| Create a Quaternion based on the 4D vector (x,y,z,w) | |
| QuatT (T angle, const Vec3T< T > &axis) | |
Create a Quaternion calculated from a rotation of angle radians around the rotation axis axis. | |
| QuatT (T angle1, const Vec3T< T > &axis1, T angle2, const Vec3T< T > &axis2, T angle3, const Vec3T< T > &axis3) | |
| Create a Quaternion based on the concatenation between the three specified angle and axis. | |
| QuatT (T x, T y, T z, T w) | |
| Create a Quaternion with the specified scalar values. | |
| Vec3T< T > | asVec3 () const |
| Vec4T< T > | asVec4 () const |
| QuatT< T > | conj () const |
| void | get (AffineMatrix4x4T< T > &matrix) const |
Set the Rotational part of matrix from this quaternion. | |
| void | get (EulerAngles &euler) const |
| Convert this quaternion to an EulerAngles representation. | |
| void | get (OrthoMatrix3x3 &matrix) const |
| Set an OrthoMatrix3x3 to represent the same rotation as the quaternion. | |
| void | get (T &angle, agx::Vec3T< T > &axis) const |
| Convert a Quaternion to an axis and angle representation. | |
| agx::Real | getAngle () const |
| Get the rotation angle represented by the quaternion. | |
| Vec3T< T > | getAsEulerAngles (agx::EulerConvention::Convention convention=agx::EulerConvention::Convention::DEFAULT_CONVENTION) const |
| Convert to Euler anglers. | |
| void | getRotate (T &angle, T &x, T &y, T &z) const |
| Get the angle and vector components represented by the quaternion. | |
| void | getRotate (T &angle, Vec3T< T > &vec) const |
| Get the angle and vector represented by the quaternion. | |
| agx::Vec3T< T > | getUnitVector () const |
| Get the rotation unit vector represented by the quaternion. | |
| QuatT< T > | inverse () const |
| Multiplicative inverse method: q^(-1) = q^*/(q.q^*) | |
| const QuatT< T > | leftMult (const QuatT< T > &rhs) const |
| Binary left multiplication: q = p * rhs; results in the OTHER WAY AROUND: q = rhs quatmultiply p;. | |
| T | length () const |
| T | length2 () const |
| T | normalize () |
| Normalize the quat so that it has unit length. | |
| bool | operator!= (const QuatT< T > &v) const |
| const QuatT< T > | operator* (const QuatT< T > &rhs) const |
| Binary LEFT multiply: result is q = rhs quatmultiply this, even though the notation is q = this * rhs ;. | |
| Vec3T< T > | operator* (const Vec3T< T > &v) const |
| Rotate a vector by this quaternion. | |
| const QuatT< T > | operator* (T rhs) const |
Multiply by scalar rhs. | |
| QuatT< T > & | operator*= (const QuatT< T > &rhs) |
| Unary LEFT multiply: result is this = rhs quatmultiply this, which makes sense since the notation suggests this = rhs * this ;. | |
| QuatT< T > & | operator*= (T rhs) |
Unary multiply by scalar rhs. | |
| const QuatT< T > | operator+ (const QuatT< T > &rhs) const |
| Binary addition. | |
| QuatT< T > & | operator+= (const QuatT< T > &rhs) |
| Unary addition. | |
| const QuatT< T > | operator- () const |
| Negation operator - returns the negative of the quaternion. | |
| const QuatT< T > | operator- (const QuatT< T > &rhs) const |
| Binary subtraction. | |
| QuatT< T > & | operator-= (const QuatT< T > &rhs) |
| Unary subtraction. | |
| const QuatT< T > | operator/ (const QuatT< T > &denom) const |
| Binary divide. | |
| QuatT< T > | operator/ (T rhs) const |
Divide by scalar rhs. | |
| QuatT< T > & | operator/= (const QuatT< T > &denom) |
| Unary divide. | |
| QuatT< T > & | operator/= (T rhs) |
Unary divide by scalar rhs. | |
| QuatT< T > & | operator= (const QuatT< T > &v) |
| Assignment operator. | |
| bool | operator== (const QuatT< T > &v) const |
| Test for equality. | |
| T & | operator[] (size_t i) |
| T | operator[] (size_t i) const |
| T * | ptr () |
| const T * | ptr () const |
| const QuatT< T > | rightMult (const QuatT< T > &rhs) const |
| Binary RIGHT multiplication: q = p * rhs ; results in q = p quatmultiply rhs ;. | |
| QuatT< T > & | set (const AffineMatrix4x4T< T > &matrix) |
Set this quaternion with the rotational part of matrix. | |
| QuatT< T > & | set (const EulerAngles &euler) |
| Set this quaternion with the rotation described by the EulerAngles representation. | |
| QuatT< T > & | set (const OrthoMatrix3x3 &matrix) |
| Set this quaternion with the rotation described by a OrthoMatrix3x3. | |
| void | set (const Vec4T< T > &v) |
| Set the four elements of the quaternion as an Vec4. | |
| void | set (T x, T y, T z, T w) |
| Set the 4 elements of the quaternion as 4 scalars. | |
| void | setRotate (const Vec3T< T > &from, const Vec3T< T > &to) |
Make a rotation QuatT<T> which will rotate from to to Generally take a dot product to get the angle between these and then use a cross product to get the rotation axis Watch out for the two special cases when the vectors are co-incident or opposite in direction. | |
| void | setRotate (T angle, const Vec3T< T > &vec) |
Set the rotation of this Quaternion as a rotation angle radians around the vector vec. | |
| void | setRotate (T angle, T x, T y, T z) |
Set the rotation of the Quaternion as a rotation angle radians around the vector (x, y, z) | |
| void | setRotate (T angle1, const Vec3T< T > &axis1, T angle2, const Vec3T< T > &axis2, T angle3, const Vec3T< T > &axis3) |
| Set the rotation of this Quaternion as a concatenation of the three angle/axis rotations: | |
| void | slerp (T t, const QuatT< T > &from, const QuatT< T > &to) |
| Spherical Linear Interpolation. | |
| T & | w () |
| T | w () const |
| T & | x () |
| T | x () const |
| T & | y () |
| T | y () const |
| T & | z () |
| T | z () const |
| bool | zeroRotation () const |
Static Public Member Functions | |
| static QuatT< T > | rotate (const Vec3T< T > &from, const Vec3T< T > &to) |
Static method which constructs and returns a Quaternion from rotating vector from to vector to. | |
| static QuatT< T > | rotate (T angle, const Vec3T< T > &vec) |
Static method which constructs and returns a Quaternion from a rotation given as angle radians around the vector vec. | |
| static QuatT< T > | rotate (T angle, T x, T y, T z) |
Static method which constructs and returns a Quaternion from a rotation given as angle radians around the vector (x, y, z) | |
| static QuatT< T > | rotate (T angle1, const Vec3T< T > &axis1, T angle2, const Vec3T< T > &axis2, T angle3, const Vec3T< T > &axis3) |
| Static method which constructs and returns a Quaternion from a rotation given as a concatenation of the three angle/axis rotations: | |
Protected Attributes | |
| T | m_data [4] |
The object holding quaternions and providing operations on these.
The quaternion class holds a representation of quaternion objects and provides simple arithmetic as well as conversion utilities. In addition, the class can compute the 3x4 matrices for converting angular velocities to quaternion velocities and vice versa. The class can also convert from and to a 3x3 orthonormal matrix.
The convention adopted for quaternions is that they map a moving frame to the fixed global reference.
Definition at line 56 of file QuatTemplate.h.
| typedef T agx::QuatT< T >::Type |
Definition at line 60 of file QuatTemplate.h.
| agx::QuatT< T >::QuatT |
Default constructor. Create a Quaternion with an identity rotation.
Definition at line 408 of file QuatTemplate.h.
| agx::QuatT< T >::QuatT | ( | T | x, |
| T | y, | ||
| T | z, | ||
| T | w | ||
| ) |
Create a Quaternion with the specified scalar values.
Definition at line 417 of file QuatTemplate.h.
|
explicit |
Create a Quaternion based on the 4D vector (x,y,z,w)
Definition at line 426 of file QuatTemplate.h.
References agx::Vec4T< T >::w(), agx::Vec4T< T >::x(), agx::Vec4T< T >::y(), and agx::Vec4T< T >::z().
| agx::QuatT< T >::QuatT | ( | T | angle, |
| const Vec3T< T > & | axis | ||
| ) |
Create a Quaternion calculated from a rotation of angle radians around the rotation axis axis.
Definition at line 435 of file QuatTemplate.h.
| agx::QuatT< T >::QuatT | ( | T | angle1, |
| const Vec3T< T > & | axis1, | ||
| T | angle2, | ||
| const Vec3T< T > & | axis2, | ||
| T | angle3, | ||
| const Vec3T< T > & | axis3 | ||
| ) |
Create a Quaternion based on the concatenation between the three specified angle and axis.
Definition at line 441 of file QuatTemplate.h.
| agx::QuatT< T >::QuatT | ( | const Vec3T< T > & | from, |
| const Vec3T< T > & | to | ||
| ) |
Create a Quaternion which maps the rotation from vector from to the vector to.
Definition at line 449 of file QuatTemplate.h.
|
explicit |
Create a Quaternion based on the rotation from euler specified as a EulerAngle.
|
default |
Copy constructor.
|
explicit |
Copy constructor for other types.
Definition at line 457 of file QuatTemplate.h.
|
explicit |
Create a Quaternion based on the rotation part in the specified Affine 4x4 transformation matrix.
Definition at line 466 of file QuatTemplate.h.
| Vec3T< T > agx::QuatT< T >::asVec3 |
Definition at line 501 of file QuatTemplate.h.
| Vec4T< T > agx::QuatT< T >::asVec4 |
Definition at line 495 of file QuatTemplate.h.
| QuatT< T > agx::QuatT< T >::conj |
Definition at line 730 of file QuatTemplate.h.
| void agx::QuatT< T >::get | ( | AffineMatrix4x4T< T > & | matrix | ) | const |
Set the Rotational part of matrix from this quaternion.
| matrix | - reference to the matrix where the result will be written. |
| void agx::QuatT< T >::get | ( | EulerAngles & | euler | ) | const |
Convert this quaternion to an EulerAngles representation.
param euler - reference to where the result will be written.
| void agx::QuatT< T >::get | ( | OrthoMatrix3x3 & | matrix | ) | const |
Set an OrthoMatrix3x3 to represent the same rotation as the quaternion.
| matrix | - reference to the matrix where the result will be written. |
| void agx::QuatT< T >::get | ( | T & | angle, |
| agx::Vec3T< T > & | axis | ||
| ) | const |
Convert a Quaternion to an axis and angle representation.
| axis | - reference to which the axis will be written |
| angle | - reference to the real value where the angle will be written |
| agx::Real agx::QuatT< T >::getAngle | ( | ) | const |
Get the rotation angle represented by the quaternion.
| Vec3T< T > agx::QuatT< T >::getAsEulerAngles | ( | agx::EulerConvention::Convention | convention = agx::EulerConvention::Convention::DEFAULT_CONVENTION | ) | const |
Convert to Euler anglers.
and retrieve as a Vec3 with the angles stored.
| convention | - The specified convention for EulerAngles |
| void agx::QuatT< T >::getRotate | ( | T & | angle, |
| T & | x, | ||
| T & | y, | ||
| T & | z | ||
| ) | const |
Get the angle and vector components represented by the quaternion.
Referenced by agx::RigidBody::getCmRotation(), agx::RigidBody::getRotation(), and agxCollide::Geometry::getRotation().
| void agx::QuatT< T >::getRotate | ( | T & | angle, |
| Vec3T< T > & | vec | ||
| ) | const |
Get the angle and vector represented by the quaternion.
| agx::Vec3T< T > agx::QuatT< T >::getUnitVector | ( | ) | const |
Get the rotation unit vector represented by the quaternion.
| QuatT< T > agx::QuatT< T >::inverse |
Multiplicative inverse method: q^(-1) = q^*/(q.q^*)
Definition at line 736 of file QuatTemplate.h.
Referenced by agx::QuatT< T >::operator/(), and agx::QuatT< T >::operator/=().
| const QuatT< T > agx::QuatT< T >::leftMult | ( | const QuatT< T > & | rhs | ) | const |
Binary left multiplication: q = p * rhs; results in the OTHER WAY AROUND: q = rhs quatmultiply p;.
Definition at line 634 of file QuatTemplate.h.
| T agx::QuatT< T >::length |
Definition at line 718 of file QuatTemplate.h.
| T agx::QuatT< T >::length2 |
Definition at line 724 of file QuatTemplate.h.
| T agx::QuatT< T >::normalize |
Normalize the quat so that it has unit length.
Returns the previous length of the quat.
Definition at line 789 of file QuatTemplate.h.
| bool agx::QuatT< T >::operator!= | ( | const QuatT< T > & | v | ) | const |
v is not identical to this quaternion Definition at line 489 of file QuatTemplate.h.
References agx::QuatT< T >::m_data.
| const QuatT< T > agx::QuatT< T >::operator* | ( | const QuatT< T > & | rhs | ) | const |
Binary LEFT multiply: result is q = rhs quatmultiply this, even though the notation is q = this * rhs ;.
Definition at line 610 of file QuatTemplate.h.
References agx::QuatT< T >::m_data.
|
inline |
Rotate a vector by this quaternion.
Definition at line 776 of file QuatTemplate.h.
| const QuatT< T > agx::QuatT< T >::operator* | ( | T | rhs | ) | const |
Multiply by scalar rhs.
Definition at line 594 of file QuatTemplate.h.
| QuatT< T > & agx::QuatT< T >::operator*= | ( | const QuatT< T > & | rhs | ) |
Unary LEFT multiply: result is this = rhs quatmultiply this, which makes sense since the notation suggests this = rhs * this ;.
Definition at line 619 of file QuatTemplate.h.
References agx::QuatT< T >::m_data.
| QuatT< T > & agx::QuatT< T >::operator*= | ( | T | rhs | ) |
Unary multiply by scalar rhs.
Definition at line 600 of file QuatTemplate.h.
| const QuatT< T > agx::QuatT< T >::operator+ | ( | const QuatT< T > & | rhs | ) | const |
| QuatT< T > & agx::QuatT< T >::operator+= | ( | const QuatT< T > & | rhs | ) |
| const QuatT< T > agx::QuatT< T >::operator- |
Negation operator - returns the negative of the quaternion.
Basically just calls operator - () on the Vec4
Definition at line 712 of file QuatTemplate.h.
| const QuatT< T > agx::QuatT< T >::operator- | ( | const QuatT< T > & | rhs | ) | const |
Binary subtraction.
Definition at line 695 of file QuatTemplate.h.
References agx::QuatT< T >::m_data.
| QuatT< T > & agx::QuatT< T >::operator-= | ( | const QuatT< T > & | rhs | ) |
Unary subtraction.
Definition at line 702 of file QuatTemplate.h.
References agx::QuatT< T >::m_data.
| const QuatT< T > agx::QuatT< T >::operator/ | ( | const QuatT< T > & | denom | ) | const |
Binary divide.
Definition at line 665 of file QuatTemplate.h.
References agx::QuatT< T >::inverse().
| QuatT< T > agx::QuatT< T >::operator/ | ( | T | rhs | ) | const |
Divide by scalar rhs.
Definition at line 647 of file QuatTemplate.h.
| QuatT< T > & agx::QuatT< T >::operator/= | ( | const QuatT< T > & | denom | ) |
| QuatT< T > & agx::QuatT< T >::operator/= | ( | T | rhs | ) |
Unary divide by scalar rhs.
Definition at line 654 of file QuatTemplate.h.
| QuatT< T > & agx::QuatT< T >::operator= | ( | const QuatT< T > & | v | ) |
Assignment operator.
Definition at line 473 of file QuatTemplate.h.
References agx::QuatT< T >::m_data.
| bool agx::QuatT< T >::operator== | ( | const QuatT< T > & | v | ) | const |
Test for equality.
v Definition at line 483 of file QuatTemplate.h.
References agx::QuatT< T >::m_data.
| T & agx::QuatT< T >::operator[] | ( | size_t | i | ) |
Definition at line 525 of file QuatTemplate.h.
References agxAssert.
| T agx::QuatT< T >::operator[] | ( | size_t | i | ) | const |
Definition at line 532 of file QuatTemplate.h.
References agxAssert.
| T * agx::QuatT< T >::ptr |
Definition at line 804 of file QuatTemplate.h.
| const T * agx::QuatT< T >::ptr |
Definition at line 810 of file QuatTemplate.h.
| const QuatT< T > agx::QuatT< T >::rightMult | ( | const QuatT< T > & | rhs | ) | const |
Binary RIGHT multiplication: q = p * rhs ; results in q = p quatmultiply rhs ;.
Definition at line 640 of file QuatTemplate.h.
|
static |
Static method which constructs and returns a Quaternion from rotating vector from to vector to.
Definition at line 767 of file QuatTemplate.h.
References agx::QuatT< T >::setRotate().
|
static |
Static method which constructs and returns a Quaternion from a rotation given as angle radians around the vector vec.
Definition at line 749 of file QuatTemplate.h.
References agx::QuatT< T >::setRotate().
|
static |
Static method which constructs and returns a Quaternion from a rotation given as angle radians around the vector (x, y, z)
Definition at line 743 of file QuatTemplate.h.
|
static |
Static method which constructs and returns a Quaternion from a rotation given as a concatenation of the three angle/axis rotations:
this = q1*q2*q3
Definition at line 757 of file QuatTemplate.h.
References agx::QuatT< T >::setRotate().
| QuatT< T > & agx::QuatT< T >::set | ( | const AffineMatrix4x4T< T > & | matrix | ) |
Set this quaternion with the rotational part of matrix.
| QuatT< T > & agx::QuatT< T >::set | ( | const EulerAngles & | euler | ) |
Set this quaternion with the rotation described by the EulerAngles representation.
| QuatT< T > & agx::QuatT< T >::set | ( | const OrthoMatrix3x3 & | matrix | ) |
Set this quaternion with the rotation described by a OrthoMatrix3x3.
| void agx::QuatT< T >::set | ( | const Vec4T< T > & | v | ) |
Set the four elements of the quaternion as an Vec4.
Definition at line 516 of file QuatTemplate.h.
References agx::Vec4T< T >::w(), agx::Vec4T< T >::x(), agx::Vec4T< T >::y(), and agx::Vec4T< T >::z().
| void agx::QuatT< T >::set | ( | T | x, |
| T | y, | ||
| T | z, | ||
| T | w | ||
| ) |
Set the 4 elements of the quaternion as 4 scalars.
Definition at line 507 of file QuatTemplate.h.
| void agx::QuatT< T >::setRotate | ( | const Vec3T< T > & | from, |
| const Vec3T< T > & | to | ||
| ) |
Make a rotation QuatT<T> which will rotate from to to Generally take a dot product to get the angle between these and then use a cross product to get the rotation axis Watch out for the two special cases when the vectors are co-incident or opposite in direction.
| void agx::QuatT< T >::setRotate | ( | T | angle, |
| const Vec3T< T > & | vec | ||
| ) |
Set the rotation of this Quaternion as a rotation angle radians around the vector vec.
| void agx::QuatT< T >::setRotate | ( | T | angle, |
| T | x, | ||
| T | y, | ||
| T | z | ||
| ) |
Set the rotation of the Quaternion as a rotation angle radians around the vector (x, y, z)
Referenced by agx::QuatT< T >::rotate(), agx::AffineMatrix4x4T< T >::setRotate(), and agx::Matrix4x4T< T >::setRotate().
| void agx::QuatT< T >::setRotate | ( | T | angle1, |
| const Vec3T< T > & | axis1, | ||
| T | angle2, | ||
| const Vec3T< T > & | axis2, | ||
| T | angle3, | ||
| const Vec3T< T > & | axis3 | ||
| ) |
Set the rotation of this Quaternion as a concatenation of the three angle/axis rotations:
this = q1*q2*q3
| void agx::QuatT< T >::slerp | ( | T | t, |
| const QuatT< T > & | from, | ||
| const QuatT< T > & | to | ||
| ) |
Spherical Linear Interpolation.
As t goes from 0 to 1, the QuatT<T> object goes from from to to.
| T & agx::QuatT< T >::w |
Definition at line 557 of file QuatTemplate.h.
| T agx::QuatT< T >::w |
Definition at line 581 of file QuatTemplate.h.
| T & agx::QuatT< T >::x |
Definition at line 539 of file QuatTemplate.h.
| T agx::QuatT< T >::x |
Definition at line 563 of file QuatTemplate.h.
| T & agx::QuatT< T >::y |
Definition at line 545 of file QuatTemplate.h.
| T agx::QuatT< T >::y |
Definition at line 569 of file QuatTemplate.h.
| T & agx::QuatT< T >::z |
Definition at line 551 of file QuatTemplate.h.
| T agx::QuatT< T >::z |
Definition at line 575 of file QuatTemplate.h.
|
inline |
Definition at line 587 of file QuatTemplate.h.
|
protected |
Definition at line 402 of file QuatTemplate.h.
Referenced by agx::QuatT< T >::operator!=(), agx::QuatT< T >::operator*(), agx::QuatT< T >::operator*=(), agx::QuatT< T >::operator+(), agx::QuatT< T >::operator+=(), agx::QuatT< T >::operator-(), agx::QuatT< T >::operator-=(), agx::QuatT< T >::operator=(), and agx::QuatT< T >::operator==().