Skip to content

shz::quat

Markdown

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 quat identity() noexcept

Returns an identity quaternion.

Calls: shz_quat_identity()

static quat from_angles_xyz(float x, float y, float z) noexcept

C++ convenience wrapper for shz_quat_from_angles_xyz().

Calls: shz_quat_from_angles_xyz()

static quat from_rotation_xyz(float x, float y, float z) noexcept

C++ convenience wrapper for shz_quat_from_rotation_xyz().

Calls: shz_quat_from_rotation_xyz()

static quat from_rotation_zyx(float z, float y, float x) noexcept

C++ convenience wrapper for shz_quat_from_rotation_zyx().

Calls: shz_quat_from_rotation_zyx()

static quat from_rotation_zxy(float z, float x, float y) noexcept

C++ convenience wrapper for shz_quat_from_rotation_zxy().

Calls: shz_quat_from_rotation_zxy()

static quat from_rotation_yxz(float y, float x, float z) noexcept

C++ convenience wrapper for shz_quat_from_rotation_yxz().

Calls: shz_quat_from_rotation_yxz()

static quat from_rotation_xyz_u16(uint16_t x, uint16_t y, uint16_t z) noexcept

C++ convenience wrapper for shz_quat_from_rotation_xyz_u16().

Calls: shz_quat_from_rotation_xyz_u16()

static quat from_rotation_zyx_u16(uint16_t z, uint16_t y, uint16_t x) noexcept

C++ convenience wrapper for shz_quat_from_rotation_zyx_u16().

Calls: shz_quat_from_rotation_zyx_u16()

static quat from_rotation_zxy_u16(uint16_t z, uint16_t x, uint16_t y) noexcept

C++ convenience wrapper for shz_quat_from_rotation_zxy_u16().

Calls: shz_quat_from_rotation_zxy_u16()

static quat from_rotation_yxz_u16(uint16_t y, uint16_t x, uint16_t z) noexcept

C++ convenience wrapper for shz_quat_from_rotation_yxz_u16().

Calls: shz_quat_from_rotation_yxz_u16()

static quat from_axis_angle(const vec3 &axis, float angle) noexcept

Initializes a quaternion which is a rotation in angle radians about the given axis.

Calls: shz_quat_from_axis_angle()

static quat from_look_axis(const vec3 &forward, const vec3 &up) noexcept

Creates a quaternion looking in the given direction with the given reference direction.

Calls: shz_quat_from_look_axis()

static quat from_rotated_axis(const vec3 &start, const vec3 &end) noexcept

Returns 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) noexcept

Returns 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) noexcept

Equivalent to lerp(), except that the resulting quaternion is normalized.

Calls: shz_quat_nlerp()

static quat slerp(const quat &q, const quat &p, float t) noexcept

Returns 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) noexcept

Evaluates the smooth cubic spherical interpolation (SQUAD) at parameter t.

Calls: shz_quat_squad()

quat() noexcept=default
quat(const quat &other) noexcept=default
quat(float w, float x, float y, float z) noexcept
quat(const shz_quat_t &q) noexcept
quat(const volatile shz_quat_t &other) noexcept

Default constructor: does nothing.

float angle() const noexcept

Returns the angle of rotation represented by the given quaternion.

Calls: shz_quat_angle()

vec3 axis() const noexcept

Returns the axis of rotation represented by the given quaternion.

Calls: shz_quat_axis()

float angle_x() const noexcept

Returns the angle of rotation about the X axis represented by the given quaternion.

Calls: shz_quat_angle_x()

float angle_y() const noexcept

Returns the angle of rotation about the Y axis represented by the given quaternion.

Calls: shz_quat_angle_y()

float angle_z() const noexcept

Returns the angle of rotation about the Z axis represented by the given quaternion.

Calls: shz_quat_angle_z()

float magnitude_sqr() const noexcept

Returns the magnitude of the quaternion squared.

Calls: shz_quat_magnitude_sqr()

float magnitude() const noexcept

Returns the magnitude of the quaternion.

Calls: shz_quat_magnitude()

float magnitude_inv() const noexcept

Returns the inverse of the magnitude of the quaternion.

Calls: shz_quat_magnitude_inv()

vec3 to_angles_xyz() const noexcept

Returns 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()

void to_axis_angle(shz_vec3_t *axis, float *angle) const noexcept
std::pair< vec3, float > to_axis_angle() const noexcept

Returns both the axis and angle of rotation through the pointer arguments.

Calls: shz_quat_to_axis_angle()

quat normalized() const noexcept

Returns the given quaternion as a unit quaternion.

Calls: shz_quat_normalize()

void normalize() noexcept

Normalizes the given quaternion.

quat normalized_safe() const noexcept

Returns a safely normalized quaternion from the given quaternion, protecting against division-by-zero.

Calls: shz_quat_normalize_safe()

void normalize_safe() noexcept

Safely normalizes the given quaternion by protecting against division-by-zero.

quat conjugated() const noexcept

Returns a quaternion that is the conjugate of the given quaternion.

Calls: shz_quat_conjugate()

void conjugate() noexcept

Conjugates the given quaternion.

quat inverse() const noexcept

Returns the inverse of the given quaternion.

Calls: shz_quat_inv()

void invert() noexcept

Inverts the given quaternion.

quat negated() const noexcept

Returns a new quaternion whose components are the negated values of the given quaternion.

Calls: shz_quat_neg()

void negate() noexcept

Negates the components of the given quaternion.

quat add(const quat &rhs) const noexcept

Returns a new quaternion from adding the given quaterion to rhs.

Calls: shz_quat_add()

quat sub(const quat &rhs) const noexcept

Returns a new quaternion from adding rhs from the given quaternion.

Calls: shz_quat_sub()

quat scaled(float s) const noexcept

Returns a new quaternion from scaling the given quaterion by s.

Calls: shz_quat_scale()

void scale(float s) noexcept

Multiplies each component of the given quaternion by s.

float dot(const quat &other) const noexcept
vec2 dot(const quat &q1, const quat &q2) const noexcept
vec3 dot(const quat &q1, const quat &q2, const quat &q3) const noexcept

Returns 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 noexcept

Returns a new quaterion from multiplying the given quaternion by another.

Calls: shz_quat_mult()

quat div(const quat &rhs) const noexcept

Returns a new quaterion from dividing the given quaternion by another (or multiplying the given quaternion by the inverse of another).

Calls: shz_quat_div()

float angle_between(const quat &p) const noexcept

Returns the angle in radians between the rotations represented by quaternions q and p.

Calls: shz_quat_angle_between()

quat rotate_towards(const quat &to, float max_angle) const noexcept

Rotates quaternion from towards quaternion to by at most max_angle radians.

Calls: shz_quat_rotate_towards()

vec3 transform(const vec3 &in) const noexcept

Returns a new shz::vec3 from transforming in by the given quaternion.

Calls: shz_quat_transform_vec3()

quat operator-() const noexcept

Overloaded unary negation operator, returns the negation of the given quaternion.

quat operator+=(const quat &rhs) noexcept

Adds and accumulates rhs onto the given quaternion.

quat operator-=(const quat &rhs) noexcept

Subtracts rhs from the given quaternion.

quat operator*=(const quat &rhs) noexcept
quat operator*=(float rhs) noexcept

Multiplies and accumulates rhs into the given quaternion.

quat operator/=(const quat &rhs) noexcept
quat operator/=(float rhs) noexcept

Divides the given quaternion by rhs.

Calls: shz_invf()

bool operator==(const quat &lhs, const quat &rhs) noexcept

Overloaded comparison operator, checks for quaternion equality.