shz::quat
C++ structure representing a quaternion.
A quaternion represents a rotation about an arbitrary axis in 3D space.
- Header:
#include <sh4zam/shz_quat.hpp>(source) - C type:
shz_quat_t(layout-compatible; the C API accepts it directly) - Bases:
shz_quat_t
Static functions
Section titled “Static functions”identity
Section titled “identity”static quat identity() noexceptReturns an identity quaternion.
Calls: shz_quat_identity()
from_angles_xyz
Section titled “from_angles_xyz”static quat from_angles_xyz(float x, float y, float z) noexceptC++ convenience wrapper for shz_quat_from_angles_xyz().
Calls: shz_quat_from_angles_xyz()
from_rotation_xyz
Section titled “from_rotation_xyz”static quat from_rotation_xyz(float x, float y, float z) noexceptC++ convenience wrapper for shz_quat_from_rotation_xyz().
Calls: shz_quat_from_rotation_xyz()
from_rotation_zyx
Section titled “from_rotation_zyx”static quat from_rotation_zyx(float z, float y, float x) noexceptC++ convenience wrapper for shz_quat_from_rotation_zyx().
Calls: shz_quat_from_rotation_zyx()
from_rotation_zxy
Section titled “from_rotation_zxy”static quat from_rotation_zxy(float z, float x, float y) noexceptC++ convenience wrapper for shz_quat_from_rotation_zxy().
Calls: shz_quat_from_rotation_zxy()
from_rotation_yxz
Section titled “from_rotation_yxz”static quat from_rotation_yxz(float y, float x, float z) noexceptC++ convenience wrapper for shz_quat_from_rotation_yxz().
Calls: shz_quat_from_rotation_yxz()
from_rotation_xyz_u16
Section titled “from_rotation_xyz_u16”static quat from_rotation_xyz_u16(uint16_t x, uint16_t y, uint16_t z) noexceptC++ convenience wrapper for shz_quat_from_rotation_xyz_u16().
Calls: shz_quat_from_rotation_xyz_u16()
from_rotation_zyx_u16
Section titled “from_rotation_zyx_u16”static quat from_rotation_zyx_u16(uint16_t z, uint16_t y, uint16_t x) noexceptC++ convenience wrapper for shz_quat_from_rotation_zyx_u16().
Calls: shz_quat_from_rotation_zyx_u16()
from_rotation_zxy_u16
Section titled “from_rotation_zxy_u16”static quat from_rotation_zxy_u16(uint16_t z, uint16_t x, uint16_t y) noexceptC++ convenience wrapper for shz_quat_from_rotation_zxy_u16().
Calls: shz_quat_from_rotation_zxy_u16()
from_rotation_yxz_u16
Section titled “from_rotation_yxz_u16”static quat from_rotation_yxz_u16(uint16_t y, uint16_t x, uint16_t z) noexceptC++ convenience wrapper for shz_quat_from_rotation_yxz_u16().
Calls: shz_quat_from_rotation_yxz_u16()
from_axis_angle
Section titled “from_axis_angle”static quat from_axis_angle(const vec3 &axis, float angle) noexceptInitializes a quaternion which is a rotation in angle radians about the given axis.
Calls: shz_quat_from_axis_angle()
from_look_axis
Section titled “from_look_axis”static quat from_look_axis(const vec3 &forward, const vec3 &up) noexceptCreates a quaternion looking in the given direction with the given reference direction.
Calls: shz_quat_from_look_axis()
from_rotated_axis
Section titled “from_rotated_axis”static quat from_rotated_axis(const vec3 &start, const vec3 &end) noexceptReturns the quaternion representing the rotation from the start to the end axes.
Calls: shz_quat_from_rotated_axis()
static quat lerp(const quat &q, const quat &p, float t) noexceptReturns the quaternion that is linearly interpolating q to p, by a t factor of 0.0f-1.0f.
Calls: shz_quat_lerp()
static quat nlerp(const quat &q, const quat &p, float t) noexceptEquivalent to lerp(), except that the resulting quaternion is normalized.
Calls: shz_quat_nlerp()
static quat slerp(const quat &q, const quat &p, float t) noexceptReturns the quaternion that is spherically linearly interpolating q to p, by a t factor of 0.0f-1.0f.
Calls: shz_quat_slerp()
static quat squad(const quat &q1, const quat &q2, const quat &s1, const quat &s2, float t) noexceptEvaluates the smooth cubic spherical interpolation (SQUAD) at parameter t.
Calls: shz_quat_squad()
Members
Section titled “Members”quat() noexcept=defaultquat(const quat &other) noexcept=defaultquat(float w, float x, float y, float z) noexceptquat(const shz_quat_t &q) noexceptquat(const volatile shz_quat_t &other) noexceptDefault constructor: does nothing.
float angle() const noexceptReturns the angle of rotation represented by the given quaternion.
Calls: shz_quat_angle()
vec3 axis() const noexceptReturns the axis of rotation represented by the given quaternion.
Calls: shz_quat_axis()
angle_x
Section titled “angle_x”float angle_x() const noexceptReturns the angle of rotation about the X axis represented by the given quaternion.
Calls: shz_quat_angle_x()
angle_y
Section titled “angle_y”float angle_y() const noexceptReturns the angle of rotation about the Y axis represented by the given quaternion.
Calls: shz_quat_angle_y()
angle_z
Section titled “angle_z”float angle_z() const noexceptReturns the angle of rotation about the Z axis represented by the given quaternion.
Calls: shz_quat_angle_z()
magnitude_sqr
Section titled “magnitude_sqr”float magnitude_sqr() const noexceptReturns the magnitude of the quaternion squared.
Calls: shz_quat_magnitude_sqr()
magnitude
Section titled “magnitude”float magnitude() const noexceptReturns the magnitude of the quaternion.
Calls: shz_quat_magnitude()
magnitude_inv
Section titled “magnitude_inv”float magnitude_inv() const noexceptReturns the inverse of the magnitude of the quaternion.
Calls: shz_quat_magnitude_inv()
to_angles_xyz
Section titled “to_angles_xyz”vec3 to_angles_xyz() const noexceptReturns the tait-bryan rotation angles about the X, Y, then Z axes which are represented by the given quaternion.
Calls: shz_quat_to_angles_xyz()
to_axis_angle
Section titled “to_axis_angle”void to_axis_angle(shz_vec3_t *axis, float *angle) const noexceptstd::pair< vec3, float > to_axis_angle() const noexceptReturns both the axis and angle of rotation through the pointer arguments.
Calls: shz_quat_to_axis_angle()
normalized
Section titled “normalized”quat normalized() const noexceptReturns the given quaternion as a unit quaternion.
Calls: shz_quat_normalize()
normalize
Section titled “normalize”void normalize() noexceptNormalizes the given quaternion.
normalized_safe
Section titled “normalized_safe”quat normalized_safe() const noexceptReturns a safely normalized quaternion from the given quaternion, protecting against division-by-zero.
Calls: shz_quat_normalize_safe()
normalize_safe
Section titled “normalize_safe”void normalize_safe() noexceptSafely normalizes the given quaternion by protecting against division-by-zero.
conjugated
Section titled “conjugated”quat conjugated() const noexceptReturns a quaternion that is the conjugate of the given quaternion.
Calls: shz_quat_conjugate()
conjugate
Section titled “conjugate”void conjugate() noexceptConjugates the given quaternion.
inverse
Section titled “inverse”quat inverse() const noexceptReturns the inverse of the given quaternion.
Calls: shz_quat_inv()
invert
Section titled “invert”void invert() noexceptInverts the given quaternion.
negated
Section titled “negated”quat negated() const noexceptReturns a new quaternion whose components are the negated values of the given quaternion.
Calls: shz_quat_neg()
negate
Section titled “negate”void negate() noexceptNegates the components of the given quaternion.
quat add(const quat &rhs) const noexceptReturns a new quaternion from adding the given quaterion to rhs.
Calls: shz_quat_add()
quat sub(const quat &rhs) const noexceptReturns a new quaternion from adding rhs from the given quaternion.
Calls: shz_quat_sub()
scaled
Section titled “scaled”quat scaled(float s) const noexceptReturns a new quaternion from scaling the given quaterion by s.
Calls: shz_quat_scale()
void scale(float s) noexceptMultiplies each component of the given quaternion by s.
float dot(const quat &other) const noexceptvec2 dot(const quat &q1, const quat &q2) const noexceptvec3 dot(const quat &q1, const quat &q2, const quat &q3) const noexceptReturns the dot product between the given quaternion and another.
Calls: shz_quat_dot(), shz_quat_dot2(), shz_quat_dot3()
quat mult(const quat &rhs) const noexceptReturns a new quaterion from multiplying the given quaternion by another.
Calls: shz_quat_mult()
quat div(const quat &rhs) const noexceptReturns a new quaterion from dividing the given quaternion by another (or multiplying the given quaternion by the inverse of another).
Calls: shz_quat_div()
angle_between
Section titled “angle_between”float angle_between(const quat &p) const noexceptReturns the angle in radians between the rotations represented by quaternions q and p.
Calls: shz_quat_angle_between()
rotate_towards
Section titled “rotate_towards”quat rotate_towards(const quat &to, float max_angle) const noexceptRotates quaternion from towards quaternion to by at most max_angle radians.
Calls: shz_quat_rotate_towards()
transform
Section titled “transform”vec3 transform(const vec3 &in) const noexceptReturns a new shz::vec3 from transforming in by the given quaternion.
Calls: shz_quat_transform_vec3()
operator-
Section titled “operator-”quat operator-() const noexceptOverloaded unary negation operator, returns the negation of the given quaternion.
operator+=
Section titled “operator+=”quat operator+=(const quat &rhs) noexceptAdds and accumulates rhs onto the given quaternion.
operator-=
Section titled “operator-=”quat operator-=(const quat &rhs) noexceptSubtracts rhs from the given quaternion.
operator*=
Section titled “operator*=”quat operator*=(const quat &rhs) noexceptquat operator*=(float rhs) noexceptMultiplies and accumulates rhs into the given quaternion.
operator/=
Section titled “operator/=”quat operator/=(const quat &rhs) noexceptquat operator/=(float rhs) noexceptDivides the given quaternion by rhs.
Calls: shz_invf()
operator==
Section titled “operator==”bool operator==(const quat &lhs, const quat &rhs) noexceptOverloaded comparison operator, checks for quaternion equality.