Euphoria
|
A quaternion representing a rotation in 3d. More...
Public Member Functions | |
constexpr | Q (float aw, const v3 &v) |
void | normalize () |
Normalize the quaternion. | |
Q | then_get_rotated (const Q &q) const |
Return the passed rotation composed after the current rotation. | |
n3 | get_rotated (const n3 &v) const |
Rotate a unit vector according to the quaternion. | |
Q | get_negated () const |
Gets the negated quaternion. | |
v3 | get_vec_part () const |
Get the [x,y,z] part as a regular 3d vector. | |
Q | get_conjugate () const |
Returns the conjugate of the quaternion. | |
Q | get_inverse () const |
Gets the inverse rotation. | |
float | get_length () const |
Gets the length of the quaternion. | |
Q | get_normalized () const |
Return a normalized quaternion If it can't be normalized, the identity is returned. | |
n3 | get_local_in () const |
Get the local in vector. | |
n3 | get_local_out () const |
Get the local out vector. | |
n3 | get_local_right () const |
Get the local right vector. | |
n3 | get_local_left () const |
Get the local left vector. | |
n3 | get_local_up () const |
Get the local up vector. | |
n3 | get_local_down () const |
Get the local down vector. | |
void | operator*= (float rhs) |
void | operator*= (const Q &rhs) |
Static Public Member Functions | |
static Q | from (const AA &aa) |
Create a quaternion from an axis angle. | |
static Q | from (const Ypr &ypr) |
Create a quaternion from a yaw-pitch-roll. | |
static Q | from_to (const Q &from, const Q &to) |
Create a quaternion going from from to to . | |
static std::optional< Q > | look_at (const v3 &from, const v3 &to, const n3 &up) |
Creates a look-at quaternion from 2 positions. | |
static Q | look_in_direction (const n3 &dir, const n3 &up) |
Creates a look-at quaternion looking in a direction. | |
static Q | nlerp (const Q &f, float scale, const Q &t) |
Normalized lerp between 2 quaternions This will result in a non-linear rotation. | |
static Q | slerp_fast (const Q &qa, float t, const Q &qb) |
Spherical lerp between 2 quaternions. | |
static Q | slerp (const Q &from, float scale, const Q &to) |
Shortest spherical lerp between 2 quaternions. | |
Public Attributes | |
float | w |
float | x |
float | y |
float | z |
Create a quaternion going from from
to to
.
Q eu::Q::get_conjugate | ( | ) | const |
Returns the conjugate of the quaternion.
Q eu::Q::get_inverse | ( | ) | const |
Gets the inverse rotation.
Implemented as a conjugate with assert that the quaternion is normalized.
float eu::Q::get_length | ( | ) | const |
Gets the length of the quaternion.
Since the quaternion should be a unit, this should always be 1
n3 eu::Q::get_local_down | ( | ) | const |
Get the local down vector.
n3 eu::Q::get_local_in | ( | ) | const |
Get the local in vector.
n3 eu::Q::get_local_left | ( | ) | const |
Get the local left vector.
n3 eu::Q::get_local_out | ( | ) | const |
Get the local out vector.
n3 eu::Q::get_local_right | ( | ) | const |
Get the local right vector.
n3 eu::Q::get_local_up | ( | ) | const |
Get the local up vector.
Q eu::Q::get_negated | ( | ) | const |
Gets the negated quaternion.
The negated represents the same rotation
Q eu::Q::get_normalized | ( | ) | const |
Return a normalized quaternion If it can't be normalized, the identity is returned.
v3 eu::Q::get_vec_part | ( | ) | const |
Get the [x,y,z]
part as a regular 3d vector.
Creates a look-at quaternion from 2 positions.
Standing at from
and up is up
, the result will be a quaternion looking at to
Creates a look-at quaternion looking in a direction.
Normalized lerp between 2 quaternions This will result in a non-linear rotation.
void eu::Q::normalize | ( | ) |
Normalize the quaternion.
If it can't be normalized, it is set to the identity.
Shortest spherical lerp between 2 quaternions.
Has extra logic to take the shortest route.
Spherical lerp between 2 quaternions.
Will take the longer route sometimes but is technically faster.
Return the passed rotation composed after the current rotation.