A simple quaternion class for rotations.
More...
#include <quaternion.hpp>
A simple quaternion class for rotations.
The quaternion operations and math are mainly based on this paper: https://jerabaul29.github.io/assets/quaternions/quaternions.pdf
◆ Quaternion() [1/4]
imunano33::Quaternion::Quaternion |
( |
| ) |
|
|
inline |
Default constructor.
Initializes quaternion to [1, 0, 0, 0]
◆ Quaternion() [2/4]
imunano33::Quaternion::Quaternion |
( |
const num_t |
w, |
|
|
const Vector3D & |
vec |
|
) |
| |
|
inline |
Constructor for a basic quaternion.
- Parameters
-
w | The scalar component |
vec | The vector component |
◆ Quaternion() [3/4]
imunano33::Quaternion::Quaternion |
( |
const Vector3D & |
vec, |
|
|
const num_t |
ang |
|
) |
| |
|
inline |
Constructor for a rotation quaternion.
- Parameters
-
vec | The vector to rotate around |
ang | The angle to rotate around by |
- Note
- A zero vector passed into vec will result in undefined behavior
◆ Quaternion() [4/4]
imunano33::Quaternion::Quaternion |
( |
const Quaternion & |
other | ) |
|
|
default |
Copy constructor.
- Parameters
-
◆ conj()
Gets the quaternion conjugate.
- Returns
- The quaternion conjugate
◆ inv()
Gets quaternion inverse.
- Returns
- Quaternion inverse
◆ norm()
num_t imunano33::Quaternion::norm |
( |
| ) |
const |
|
inline |
Gets quaternion norm.
This behaves the same as a "magnitude" in 4-dimensional vector terms.
- Returns
- Quaternion norm
◆ operator*=()
Multiplies a quaternion in place.
- Parameters
-
- Returns
- Quaternion multiplied in place
◆ rotate() [1/2]
Rotates a vector with current quaternion object.
- Parameters
-
- Returns
- The rotated vector.
◆ rotate() [2/2]
Rotates a vector.
- Parameters
-
vec | The vector to rotate |
axis | The axis of rotation |
ang | Angle of rotation |
- Returns
- The rotated vector.
◆ unit()
Gets equivalent unit quaternion.
This behaves the same as a "normalized" 4-dimensional vector.
- Note
- If the quaternion is zero, then results in undefined behavior.
- Returns
- Equivalent unit quaternion
◆ vec()
Vector3D imunano33::Quaternion::vec |
( |
| ) |
const |
|
inline |
Gets the vector component of the quaternion.
- Returns
- The vector component
◆ w()
num_t imunano33::Quaternion::w |
( |
| ) |
const |
|
inline |
Gets the scalar component of the quaternion.
- Returns
- The scalar component
The documentation for this class was generated from the following file:
- /home/runner/work/imunano33/imunano33/include/imunano33/quaternion.hpp