|
wfmath
1.0.3
A math library for the Worldforge system.
|
A normalized quaternion. More...
#include <quaternion.h>
Classes | |
| class | Identity |
Public Member Functions | |
| Quaternion (const Identity &) | |
| Quaternion () | |
| Construct a Quaternion. More... | |
| Quaternion (CoordType w_in, CoordType x_in, CoordType y_in, CoordType z_in) | |
| Construct a Quaternion from (w, x, y, z) components. More... | |
| Quaternion (int axis, CoordType angle) | |
| Construct a Quaternion giving a rotation around axis by angle. More... | |
| Quaternion (const Vector< 3 > &axis, CoordType angle) | |
| Construct a Quaternion giving a rotation around the Vector axis by angle. More... | |
| Quaternion (const Vector< 3 > &axis) | |
| Construct a Quaternion giving a rotation around the Vector axis. More... | |
| Quaternion (const Quaternion &p)=default | |
| Construct a copy of a Quaternion. More... | |
| Quaternion (const AtlasInType &a) | |
| Construct a Quaternion from an Atlas::Message::Object. More... | |
| AtlasOutType | toAtlas () const |
| Create an Atlas object from the Quaternion. More... | |
| void | fromAtlas (const AtlasInType &a) |
| Set the Quaternion's value to that given by an Atlas object. More... | |
| Quaternion & | operator= (const Quaternion &rhs)=default |
| bool | isEqualTo (const Quaternion &q, CoordType epsilon=numeric_constants< CoordType >::epsilon()) const |
| bool | operator== (const Quaternion &rhs) const |
| bool | operator!= (const Quaternion &rhs) const |
| bool | isValid () const |
| Quaternion & | identity () |
| Set the Quaternion to the identity rotation. More... | |
| Quaternion & | operator*= (const Quaternion &rhs) |
| Quaternion & | operator/= (const Quaternion &rhs) |
| Quaternion | operator* (const Quaternion &rhs) const |
| Quaternion | operator/ (const Quaternion &rhs) const |
| bool | fromRotMatrix (const RotMatrix< 3 > &m) |
| set a Quaternion's value from a RotMatrix More... | |
| Quaternion | inverse () const |
| returns the inverse of the Quaternion More... | |
| Quaternion & | rotate (const RotMatrix< 3 > &) |
| Rotate quaternion using the matrix. More... | |
| Quaternion & | rotate (const Quaternion &q) |
| rotate the quaternion using another quaternion More... | |
| Quaternion & | rotation (int axis, CoordType angle) |
| sets the Quaternion to a rotation by angle around axis More... | |
| Quaternion & | rotation (const Vector< 3 > &axis, CoordType angle) |
| sets the Quaternion to a rotation by angle around the Vector axis More... | |
| Quaternion & | rotation (const Vector< 3 > &axis) |
| sets the Quaternion to a rotation around the Vector axis More... | |
| Quaternion & | rotation (const Vector< 3 > &from, const Vector< 3 > &to) |
| Sets the Quaternion to rotate 'from' to be parallel to 'to'. More... | |
| Quaternion & | rotation (const Vector< 3 > &from, const Vector< 3 > &to, const Vector< 3 > &fallbackAxis) |
| Sets the Quaternion to rotate 'from' to be parallel to 'to'. More... | |
| CoordType | scalar () const |
| returns the scalar (w) part of the Quaternion More... | |
| const Vector< 3 > & | vector () const |
| returns the Vector (x, y, z) part of the quaternion More... | |
| void | normalize () |
| normalize to remove accumulated round-off error More... | |
| unsigned | age () const |
| current round-off age More... | |
Static Public Member Functions | |
| static const Quaternion & | IDENTITY () |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const Quaternion &p) |
| std::istream & | operator>> (std::istream &is, Quaternion &p) |
A normalized quaternion.
Definition at line 35 of file quaternion.h.
|
inline |
Construct a Quaternion from (w, x, y, z) components.
This normalizes the components so the sum of their squares is one.
Definition at line 49 of file quaternion.cpp.
References WFMath::Vector< dim >::setValid().
|
inline |
Construct a Quaternion giving a rotation around axis by angle.
Definition at line 58 of file quaternion.h.
References rotation().
Construct a Quaternion giving a rotation around the Vector axis by angle.
Definition at line 62 of file quaternion.h.
References rotation().
|
inlineexplicit |
Construct a Quaternion giving a rotation around the Vector axis.
The angle of rotating is equal to the magnitude of the Vector
Definition at line 70 of file quaternion.h.
References rotation().
|
default |
Construct a copy of a Quaternion.
|
inlineexplicit |
Construct a Quaternion from an Atlas::Message::Object.
Definition at line 76 of file quaternion.h.
References fromAtlas().
|
inline |
current round-off age
Definition at line 187 of file quaternion.h.
|
inline |
Set the Quaternion's value to that given by an Atlas object.
Definition at line 127 of file atlasconv.h.
Referenced by Quaternion().
| bool WFMath::Quaternion::fromRotMatrix | ( | const RotMatrix< 3 > & | m | ) |
set a Quaternion's value from a RotMatrix
Since a Quaternion can only represent an even-parity RotMatrix, this function returns false if the parity of m is odd. In this case, the quaternion is set to the value of m multiplied by a fixed parity-odd RotMatrix, so the full RotMatrix can be recovered by passing the Quaternion and the value of 'not_flip' returned by this function to RotMatrix::fromQuaternion().
Definition at line 138 of file quaternion.cpp.
References WFMath::RotMatrix< dim >::age(), WFMath::RotMatrix< dim >::elem(), WFMath::RotMatrix< dim >::parity(), WFMath::Prod(), WFMath::Vector< dim >::setValid(), and WFMath::RotMatrix< dim >::trace().
Referenced by rotate().
|
static |
Gets a static identity quaternion.
Definition at line 64 of file quaternion.cpp.
References Quaternion().
|
inline |
Set the Quaternion to the identity rotation.
Definition at line 102 of file quaternion.h.
References WFMath::Vector< dim >::zero().
| Quaternion WFMath::Quaternion::inverse | ( | ) | const |
returns the inverse of the Quaternion
Definition at line 189 of file quaternion.cpp.
| void WFMath::Quaternion::normalize | ( | ) |
normalize to remove accumulated round-off error
Definition at line 322 of file quaternion.cpp.
References WFMath::Vector< dim >::sqrMag().
|
inline |
rotate the quaternion using another quaternion
Definition at line 145 of file quaternion.h.
| Quaternion & WFMath::Quaternion::rotate | ( | const RotMatrix< 3 > & | m | ) |
Rotate quaternion using the matrix.
Definition at line 198 of file quaternion.cpp.
References fromRotMatrix().
| Quaternion & WFMath::Quaternion::rotation | ( | const Vector< 3 > & | axis | ) |
sets the Quaternion to a rotation around the Vector axis
The rotation angle is given by the magnitude of the Vector
Definition at line 247 of file quaternion.cpp.
References WFMath::Vector< dim >::mag().
| Quaternion & WFMath::Quaternion::rotation | ( | const Vector< 3 > & | axis, |
| CoordType | angle | ||
| ) |
sets the Quaternion to a rotation by angle around the Vector axis
Definition at line 228 of file quaternion.cpp.
References WFMath::Vector< dim >::mag().
| Quaternion & WFMath::Quaternion::rotation | ( | const Vector< 3 > & | from, |
| const Vector< 3 > & | to | ||
| ) |
Sets the Quaternion to rotate 'from' to be parallel to 'to'.
| from | The vector to rotate from. |
| to | The vector to rotate to. |
If the vectors are colinear a ColinearVectors exception is thrown. If this is undesirable see rotation(const Vector<3>&, const Vector<3>&, const Vector<3>&) instead
Definition at line 266 of file quaternion.cpp.
References WFMath::Cross(), and WFMath::Vector< dim >::sqrMag().
| Quaternion & WFMath::Quaternion::rotation | ( | const Vector< 3 > & | from, |
| const Vector< 3 > & | to, | ||
| const Vector< 3 > & | fallbackAxis | ||
| ) |
Sets the Quaternion to rotate 'from' to be parallel to 'to'.
| from | The vector to rotate from. |
| to | The vector to rotate to. |
| fallbackAxis | If the vectors are colinear, rotate around this axis instead. |
Definition at line 294 of file quaternion.cpp.
References WFMath::Cross(), rotation(), and WFMath::Vector< dim >::sqrMag().
| Quaternion & WFMath::Quaternion::rotation | ( | int | axis, |
| CoordType | angle | ||
| ) |
sets the Quaternion to a rotation by angle around axis
Definition at line 207 of file quaternion.cpp.
References WFMath::Vector< dim >::setValid().
Referenced by Quaternion(), and rotation().
|
inline |
returns the scalar (w) part of the Quaternion
Definition at line 180 of file quaternion.h.
|
inline |
Create an Atlas object from the Quaternion.
Definition at line 172 of file atlasconv.h.
|
inline |
returns the Vector (x, y, z) part of the quaternion
Definition at line 182 of file quaternion.h.