2
3
4
5
6
7
8
9
10
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 struct quat:
public shz_quat_t {
46 SHZ_FORCE_INLINE
quat(
float w,
float x,
float y,
float z)
noexcept:
47 shz_quat_t({w, x, y, z}) {}
50 SHZ_FORCE_INLINE
quat(shz_quat_t q)
noexcept:
65 return shz_quat_from_axis_angle(axis, angle);
70 return shz_quat_from_look_axis(forward, up);
75 return shz_quat_from_rotated_axis(start, end);
89
90
91
92
130 SHZ_FORCE_INLINE
float angle()
const noexcept {
140 SHZ_FORCE_INLINE
float angle_x()
const noexcept {
141 return shz_quat_angle_x(*
this);
145 SHZ_FORCE_INLINE
float angle_y()
const noexcept {
146 return shz_quat_angle_y(*
this);
150 SHZ_FORCE_INLINE
float angle_z()
const noexcept {
151 return shz_quat_angle_z(*
this);
154 SHZ_FORCE_INLINE
vec3 to_angles_xyz()
const noexcept {
159 SHZ_FORCE_INLINE
void to_axis_angle(shz_vec3_t* axis,
float* angle)
const noexcept {
165 std::pair<
vec3,
float> aa;
166 shz_quat_to_axis_angle(*
this, &std::get<0>(aa), &std::get<1>(aa));
216 SHZ_FORCE_INLINE
void invert()
noexcept {
236 SHZ_FORCE_INLINE
float dot(
quat other)
const noexcept {
257 return shz_quat_transform_vec3(*
this, in);
Namespace enclosing the SH4ZAM C++ API.
float shz_quat_magnitude_sqr(shz_quat_t quat) SHZ_NOEXCEPT
Returns the squared magnitude of the given quaternion.
float shz_quat_magnitude(shz_quat_t quat) SHZ_NOEXCEPT
Returns the magnitude of the given quaternion.
shz_vec3_t shz_quat_axis(shz_quat_t q) SHZ_NOEXCEPT
Returns the axis of rotation from the given quaternion.
shz_quat_t shz_quat_inv(shz_quat_t quat) SHZ_NOEXCEPT
Returns the inverse of the given quaternion.
shz_quat_t shz_quat_nlerp(shz_quat_t a, shz_quat_t b, float t) SHZ_NOEXCEPT
Equivalent to shz_quat_lerp(), except that the resulting quaternion is normalized.
shz_quat_t shz_quat_scale(shz_quat_t q, float f) SHZ_NOEXCEPT
Scales the components of the given quaternion by the given factor.
bool shz_quat_equal(shz_quat_t a, shz_quat_t b) SHZ_NOEXCEPT
Returns true if the two given quaternions are considered equal based on either absolute or relative t...
#define SHZ_QUAT_SLERP_PHI_EPSILON
Minimum epsilon below which shz_quat_slerp() performs no interpolation.
shz_quat_t shz_quat_add(shz_quat_t q, shz_quat_t p) SHZ_NOEXCEPT
Returns the quaternion produced from adding each component of the given quaternions.
float shz_quat_magnitude_inv(shz_quat_t quat) SHZ_NOEXCEPT
Returns the inverse magnitude of the given quaternion.
float shz_quat_angle(shz_quat_t q) SHZ_NOEXCEPT
Returns the angle of rotation from the given quaternion.
shz_quat_t shz_quat_slerp(shz_quat_t q, shz_quat_t p, float t) SHZ_NOEXCEPT
Returns the quaternion that is spherically linearly interpolating a to b, by a t factor of 0....
shz_quat_t shz_quat_normalize_safe(shz_quat_t quat) SHZ_NOEXCEPT
SAFELY returns the normalized form of the given quaternion.
shz_quat_t shz_quat_lerp(shz_quat_t a, shz_quat_t b, float t) SHZ_NOEXCEPT
Returns the quaternion that is linearly interpolating a to b, by a t factor of 0.0f-1....
shz_vec3_t shz_quat_to_angles_xyz(shz_quat_t q) SHZ_NOEXCEPT
Returns the roll, pitch, and yaw angles of rotation represented by the given quaternion.
shz_vec2_t shz_quat_dot2(shz_quat_t l, shz_quat_t r1, shz_quat_t r2) SHZ_NOEXCEPT
Returns the two dot products taken between the l quaternion and the r1 and r2 quaternions.
shz_quat_t shz_quat_normalize(shz_quat_t quat) SHZ_NOEXCEPT
Returns the normalized form of the given quaternion.
float shz_quat_dot(shz_quat_t q1, shz_quat_t q2) SHZ_NOEXCEPT
Returns the dot product of the two quaternions.
shz_quat_t shz_quat_identity(void) SHZ_NOEXCEPT
Initializes and returns an identity quaternion.
void shz_quat_to_axis_angle(shz_quat_t q, shz_vec3_t *vec, float *angle) SHZ_NOEXCEPT
Returns both the axis and angle of rotation simultaneously (faster if both are needed) from the given...
shz_vec3_t shz_quat_dot3(shz_quat_t l, shz_quat_t r1, shz_quat_t r2, shz_quat_t r3) SHZ_NOEXCEPT
Returns the two dot products taken between the l quaternion and the r1, r2, and r3 quaternions.
shz_quat_t shz_quat_from_angles_xyz(float xangle, float yangle, float zangle) SHZ_NOEXCEPT
Initializes and returns a quaternion with the given X-Y-Z rotations in radians.
shz_quat_t shz_quat_conjugate(shz_quat_t quat) SHZ_NOEXCEPT
Returns the conjugate of the given quaternion.
shz_quat_t shz_quat_mult(shz_quat_t q1, shz_quat_t q2) SHZ_NOEXCEPT
Multiplies the two quaternions, returning the result as a new quaternion.
C++ structure representing a quaternion.
static quat nlerp(quat q, quat p, float t) noexcept
Equivalent to lerp(), except that the resulting quaternion is normalized.
float angle() const noexcept
Returns the angle of rotation represented by the given quaternion.
static quat identity() noexcept
Returns an identity quaternion.
quat normalized_safe() const noexcept
Returns a safely normalized quaternion from the given quaternion, protecting against division-by-zero...
quat scale(float s) const noexcept
Returns a new quaternion from scaling the given quaterion by s.
quat mult(quat rhs) const noexcept
Returns a new quaterion from multiplying the given quaternion by another.
quat(shz_quat_t q) noexcept
C Converting constructor: constructs a C++ shz::quat from a C shz_quat_t.
quat add(quat rhs) const noexcept
Returns a new quaternion from adding the given quaterion to rhs.
vec3 axis() const noexcept
Returns the axis of rotation represented by the given quaternion.
float magnitude_inv() const noexcept
Returns the inverse of the magnitude of the quaternion.
static quat from_rotated_axis(vec3 start, vec3 end) noexcept
Returns the quaternion representing the rotation from the start to the end axes.
vec3 transform(vec3 in) const noexcept
Returns a new shz::vec3 from transforming in by the given quaternion.
auto to_axis_angle() const noexcept -> std::pair< vec3, float >
Returns both the axis and angle of rotation as a std::pair.
void conjugate() noexcept
Conjugates the given quaternion.
static constexpr float slerp_phi_epsilon
Minimum epsilon for bothering to interpolate in shz::quat::slerp().
float dot(quat other) const noexcept
Returns the dot product between the given quaternion and another.
static quat from_axis_angle(vec3 axis, float angle) noexcept
initializes a quaternion which is a rotation in angle degrees about the given axis.
float angle_y() const noexcept
Returns the angle of rotation about the Y axis represented by the given quaternion.
static quat slerp(quat q, quat p, float t) noexcept
Returns the quaternion that is spherically linearly interpolating q to p, by a t factor of 0....
vec3 dot(quat q1, quat q2, quat q3) const noexcept
Returns the dot product of the given quaternion against three others.
void invert() noexcept
Inverts the given quaternion.
void normalize() noexcept
Normalizes the given quaternion.
quat conjugated() const noexcept
Returns a quaternion that is the conjugate of the given quaternion.
static quat lerp(quat q, quat p, float t) noexcept
Returns the quaternion that is linearly interpolating q to p, by a t factor of 0.0f-1....
float magnitude() const noexcept
Returns the magnitude of the quaternion.
quat() noexcept=default
Default constructor: does nothing.
quat normalized() const noexcept
Returns the given quaternion as a unit quaternion.
friend auto operator==(quat lhs, quat rhs) noexcept
Overloaded comparison operator, checks for quaternion equality.
float angle_x() const noexcept
Returns the angle of rotation about the X axis represented by the given quaternion.
float magnitude_sqr() const noexcept
Returns the magnitude of the quaternion squared.
static quat from_angles_xyz(float x, float y, float z) noexcept
C++ convenience wrapper for shz_quat_From_angles_xyz().
quat inverse() const noexcept
Returns the inverse of the given quaternion.
quat(float w, float x, float y, float z) noexcept
Value constructor: initializes a quaternion with the given values for each component.
void normalize_safe() noexcept
Safely normalizes the given quaternion by protecting against division-by-zero.
static quat from_look_axis(vec3 forward, vec3 up) noexcept
Creates a quaternion looking in the given direction with the given reference direction.
void to_axis_angle(shz_vec3_t *axis, float *angle) const noexcept
Returns both the axis and angle of rotation through the pointer arguments.
vec2 dot(quat q1, quat q2) const noexcept
Returns the dot product of the given quaternion against two others.
float angle_z() const noexcept
Returns the angle of rotation about the Z axis represented by the given quaternion.