SH4ZAM! 0.7.0
Fast math library for the Sega Dreamcast's SH4 CPU
Loading...
Searching...
No Matches
shz::quat Struct Reference

#include <shz_quat.hpp>

Inheritance diagram for shz::quat:
Collaboration diagram for shz::quat:

Public Member Functions

quat operator- () const noexcept
 
quat operator+= (const quat &rhs) noexcept
 
quat operator-= (const quat &rhs) noexcept
 
quat operator*= (const quat &rhs) noexcept
 
quat operator/= (const quat &rhs) noexcept
 
quat operator*= (float rhs) noexcept
 
quat operator/= (float rhs) noexcept
 
Properties

Routines for accessing or extracting values.

float angle () const noexcept
 
vec3 axis () const noexcept
 
float angle_x () const noexcept
 
float angle_y () const noexcept
 
float angle_z () const noexcept
 
float magnitude_sqr () const noexcept
 
float magnitude () const noexcept
 
float magnitude_inv () const noexcept
 
Conversions

Routines for converting to other types.

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

Routines for applying modifiers to an existing quaternion.

quat normalized () const noexcept
 
void normalize () noexcept
 
quat normalized_safe () const noexcept
 
void normalize_safe () noexcept
 
quat conjugated () const noexcept
 
void conjugate () noexcept
 
quat inverse () const noexcept
 
void invert () noexcept
 
quat negated () const noexcept
 
void negate () noexcept
 
Arithmetic

Routines performing calculations with quaternions.

quat add (const quat &rhs) const noexcept
 
quat sub (const quat &rhs) const noexcept
 
quat scaled (float s) const noexcept
 
void scale (float s) noexcept
 
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
 
quat mult (const quat &rhs) const noexcept
 
quat div (const quat &rhs) const noexcept
 
Miscellaneous

Other types of quaternion operations.

float angle_between (const quat &p) const noexcept
 
quat rotate_towards (const quat &to, float max_angle) const noexcept
 
Transformations

Routines for applying quaternion transforms.

vec3 transform (const vec3 &in) const noexcept
 

Friends

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

Initialization

Routines for creating and initializing quaternions.

 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
 
static quat identity () noexcept
 
static quat from_angles_xyz (float x, float y, float z) noexcept
 
static quat from_axis_angle (const vec3 &axis, float angle) noexcept
 
static quat from_look_axis (const vec3 &forward, const vec3 &up) noexcept
 
static quat from_rotated_axis (const vec3 &start, const vec3 &end) noexcept
 
static quat lerp (const quat &q, const quat &p, float t) noexcept
 
static quat nlerp (const quat &q, const quat &p, float t) noexcept
 
static quat slerp (const quat &q, const quat &p, float t) noexcept
 
static quat squad (const quat &q1, const quat &q2, const quat &s1, const quat &s2, float t) noexcept
 

Additional Inherited Members

- Data Fields inherited from shz_quat_t
union { 
 
   struct { 
 
      float   w 
 
      union { 
 
         struct { 
 
            float   x 
 
            float   y 
 
            float   z 
 
         }  
 
         shz_vec3_t   axis 
 
      }  
 
   }  
 
   float   e [4] 
 
};  
 

Detailed Description

C++ structure representing a quaternion.

A quaternion represents a rotation about an arbitrary axis in 3D space.

Warning
The SH4ZAM internal quaternion representation puts the W or angle component first, followed by the X, Y, Z components for the axis!
Note
shz::quat is the C++ extension of shz_quat_t, which adds member functions, convenience operators, and still retains backwards compatibility with the C API.
See also
shz_quat_t, shz::mat4x4, shz::vec3

Definition at line 38 of file shz_quat.hpp.

Constructor & Destructor Documentation

◆ quat() [1/5]

shz::quat::quat ( )
defaultnoexcept

Default constructor: does nothing.

◆ quat() [2/5]

shz::quat::quat ( const quat & other)
defaultnoexcept

Default copy constructor.

◆ quat() [3/5]

shz::quat::quat ( float w,
float x,
float y,
float z )
inlinenoexcept

Value constructor: initializes a quaternion with the given values for each component.

Definition at line 52 of file shz_quat.hpp.

52 :
53 shz_quat_t({w, x, y, z}) {}
float z
Z component of axis of rotation (imaginary)
Definition shz_quat.h:39
float w
< Anonymous structure with named components.
Definition shz_quat.h:34
float y
Y component of axis of rotation (imaginary)
Definition shz_quat.h:38
float x
X component of axis of rotation (imaginary)
Definition shz_quat.h:37

◆ quat() [4/5]

shz::quat::quat ( const shz_quat_t & q)
inlinenoexcept

C Converting constructor: constructs a C++ shz::quat from a C shz_quat_t.

Definition at line 56 of file shz_quat.hpp.

56 :
57 shz_quat_t(q) {}

◆ quat() [5/5]

shz::quat::quat ( const volatile shz_quat_t & other)
inlinenoexcept

Converting constructor from existing volatile C instance.

Definition at line 60 of file shz_quat.hpp.

60 :
61 shz_quat_t(const_cast<const shz_quat_t&>(other)) {}

Member Function Documentation

◆ identity()

static quat shz::quat::identity ( )
inlinestaticnoexcept

Returns an identity quaternion.

Definition at line 64 of file shz_quat.hpp.

64 {
65 return shz_quat_identity();
66 }
shz_quat_t shz_quat_identity(void) SHZ_NOEXCEPT
Initializes and returns an identity quaternion.

◆ from_angles_xyz()

static quat shz::quat::from_angles_xyz ( float x,
float y,
float z )
inlinestaticnoexcept

C++ convenience wrapper for shz_quat_from_angles_xyz().

Definition at line 69 of file shz_quat.hpp.

69 {
70 return shz_quat_from_angles_xyz(x, y, z);
71 }
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.

◆ from_axis_angle()

static quat shz::quat::from_axis_angle ( const vec3 & axis,
float angle )
inlinestaticnoexcept

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

Definition at line 74 of file shz_quat.hpp.

74 {
76 }
shz_quat_t shz_quat_from_axis_angle(shz_vec3_t axis, float angle) SHZ_NOEXCEPT
Initializes and returns a quaternion representing a rotation of angle radians about the given axis.
float angle() const noexcept
Returns the angle of rotation represented by the given quaternion.
Definition shz_quat.hpp:170
vec3 axis() const noexcept
Returns the axis of rotation represented by the given quaternion.
Definition shz_quat.hpp:175

◆ from_look_axis()

static quat shz::quat::from_look_axis ( const vec3 & forward,
const vec3 & up )
inlinestaticnoexcept

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

Definition at line 79 of file shz_quat.hpp.

79 {
80 return shz_quat_from_look_axis(forward, up);
81 }
shz_quat_t shz_quat_from_look_axis(shz_vec3_t forward, shz_vec3_t up) SHZ_NOEXCEPT
Creates a quaternion looking in the given direction with the given reference direction.

◆ from_rotated_axis()

static quat shz::quat::from_rotated_axis ( const vec3 & start,
const vec3 & end )
inlinestaticnoexcept

Returns the quaternion representing the rotation from the start to the end axes.

Definition at line 84 of file shz_quat.hpp.

84 {
85 return shz_quat_from_rotated_axis(start, end);
86 }
shz_quat_t shz_quat_from_rotated_axis(shz_vec3_t v1, shz_vec3_t v2) SHZ_NOEXCEPT
Returns the quaternion representing the rotation from axis v1 to v2.

◆ lerp()

static quat shz::quat::lerp ( const quat & q,
const quat & p,
float t )
inlinestaticnoexcept

Returns the quaternion that is linearly interpolating q to p, by a t factor of 0.0f-1.0f.

Definition at line 89 of file shz_quat.hpp.

89 {
90 return shz_quat_lerp(q, p, t);
91 }
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....

◆ nlerp()

static quat shz::quat::nlerp ( const quat & q,
const quat & p,
float t )
inlinestaticnoexcept

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

Definition at line 94 of file shz_quat.hpp.

94 {
95 return shz_quat_nlerp(q, p, t);
96 }
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.

◆ slerp()

static quat shz::quat::slerp ( const quat & q,
const quat & p,
float t )
inlinestaticnoexcept

Returns the quaternion that is spherically linearly interpolating q to p, by a t factor of 0.0f-1.0f.

Definition at line 99 of file shz_quat.hpp.

99 {
100 return shz_quat_slerp(q, p, t);
101 }
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....

◆ squad()

static quat shz::quat::squad ( const quat & q1,
const quat & q2,
const quat & s1,
const quat & s2,
float t )
inlinestaticnoexcept

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

Definition at line 104 of file shz_quat.hpp.

104 {
105 return shz_quat_squad(q1, q2, s1, s2, t);
106 }
shz_quat_t shz_quat_squad(shz_quat_t q1, shz_quat_t q2, shz_quat_t s1, shz_quat_t s2, float t) SHZ_NOEXCEPT
Evaluates a smooth cubic spherical interpolation (SQUAD) at parameter t.

◆ angle()

float shz::quat::angle ( ) const
inlinenoexcept

Returns the angle of rotation represented by the given quaternion.

Definition at line 170 of file shz_quat.hpp.

170 {
171 return shz_quat_angle(*this);
172 }
float shz_quat_angle(shz_quat_t q) SHZ_NOEXCEPT
Returns the angle of rotation from the given quaternion.

◆ axis()

vec3 shz::quat::axis ( ) const
inlinenoexcept

Returns the axis of rotation represented by the given quaternion.

Definition at line 175 of file shz_quat.hpp.

175 {
176 return shz_quat_axis(*this);
177 }
shz_vec3_t shz_quat_axis(shz_quat_t q) SHZ_NOEXCEPT
Returns the axis of rotation from the given quaternion.

◆ angle_x()

float shz::quat::angle_x ( ) const
inlinenoexcept

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

Definition at line 180 of file shz_quat.hpp.

180 {
181 return shz_quat_angle_x(*this);
182 }
float shz_quat_angle_x(shz_quat_t q) SHZ_NOEXCEPT
Returns the angle of rotation the quaternion represents about the X axis in radians.

◆ angle_y()

float shz::quat::angle_y ( ) const
inlinenoexcept

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

Definition at line 185 of file shz_quat.hpp.

185 {
186 return shz_quat_angle_y(*this);
187 }
float shz_quat_angle_y(shz_quat_t q) SHZ_NOEXCEPT
Returns the angle of rotation the quaternion represents about the Y axis in radians.

◆ angle_z()

float shz::quat::angle_z ( ) const
inlinenoexcept

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

Definition at line 190 of file shz_quat.hpp.

190 {
191 return shz_quat_angle_z(*this);
192 }
float shz_quat_angle_z(shz_quat_t q) SHZ_NOEXCEPT
Returns the angle of rotation the quaternion represents about the Z axis in radians.

◆ magnitude_sqr()

float shz::quat::magnitude_sqr ( ) const
inlinenoexcept

Returns the magnitude of the quaternion squared.

Definition at line 195 of file shz_quat.hpp.

195 {
196 return shz_quat_magnitude_sqr(*this);
197 }
float shz_quat_magnitude_sqr(shz_quat_t quat) SHZ_NOEXCEPT
Returns the squared magnitude of the given quaternion.

◆ magnitude()

float shz::quat::magnitude ( ) const
inlinenoexcept

Returns the magnitude of the quaternion.

Definition at line 200 of file shz_quat.hpp.

200 {
201 return shz_quat_magnitude(*this);
202 }
float shz_quat_magnitude(shz_quat_t quat) SHZ_NOEXCEPT
Returns the magnitude of the given quaternion.

◆ magnitude_inv()

float shz::quat::magnitude_inv ( ) const
inlinenoexcept

Returns the inverse of the magnitude of the quaternion.

Definition at line 205 of file shz_quat.hpp.

205 {
206 return shz_quat_magnitude_inv(*this);
207 }
float shz_quat_magnitude_inv(shz_quat_t quat) SHZ_NOEXCEPT
Returns the inverse magnitude of the given quaternion.

◆ to_angles_xyz()

vec3 shz::quat::to_angles_xyz ( ) const
inlinenoexcept

Returns the tait-bryan rotation angles about the X, Y, then Z axes which are represented by the given quaternion.

Definition at line 217 of file shz_quat.hpp.

217 {
218 return shz_quat_to_angles_xyz(*this);
219 }
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.

◆ to_axis_angle() [1/2]

void shz::quat::to_axis_angle ( shz_vec3_t * axis,
float * angle ) const
inlinenoexcept

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

Definition at line 222 of file shz_quat.hpp.

222 {
224 }
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...

◆ to_axis_angle() [2/2]

auto shz::quat::to_axis_angle ( ) const -> std::pair<vec3, float>
inlinenoexcept

Returns both the axis and angle of rotation as a std::pair.

Definition at line 227 of file shz_quat.hpp.

227 {
228 std::pair<vec3, float> aa;
229 shz_quat_to_axis_angle(*this, &std::get<0>(aa), &std::get<1>(aa));
230 return aa;
231 }

◆ normalized()

quat shz::quat::normalized ( ) const
inlinenoexcept

Returns the given quaternion as a unit quaternion.

Definition at line 241 of file shz_quat.hpp.

241 {
242 return shz_quat_normalize(*this);
243 }
shz_quat_t shz_quat_normalize(shz_quat_t quat) SHZ_NOEXCEPT
Returns the normalized form of the given quaternion.

◆ normalize()

void shz::quat::normalize ( )
inlinenoexcept

Normalizes the given quaternion.

Definition at line 246 of file shz_quat.hpp.

246 {
247 *this = normalized();
248 }
quat normalized() const noexcept
Returns the given quaternion as a unit quaternion.
Definition shz_quat.hpp:241

◆ normalized_safe()

quat shz::quat::normalized_safe ( ) const
inlinenoexcept

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

Definition at line 251 of file shz_quat.hpp.

251 {
252 return shz_quat_normalize_safe(*this);
253 }
shz_quat_t shz_quat_normalize_safe(shz_quat_t quat) SHZ_NOEXCEPT
SAFELY returns the normalized form of the given quaternion.

◆ normalize_safe()

void shz::quat::normalize_safe ( )
inlinenoexcept

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

Definition at line 256 of file shz_quat.hpp.

256 {
257 *this = normalized_safe();
258 }
quat normalized_safe() const noexcept
Returns a safely normalized quaternion from the given quaternion, protecting against division-by-zero...
Definition shz_quat.hpp:251

◆ conjugated()

quat shz::quat::conjugated ( ) const
inlinenoexcept

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

Definition at line 261 of file shz_quat.hpp.

261 {
262 return shz_quat_conjugate(*this);
263 }
shz_quat_t shz_quat_conjugate(shz_quat_t quat) SHZ_NOEXCEPT
Returns the conjugate of the given quaternion.

◆ conjugate()

void shz::quat::conjugate ( )
inlinenoexcept

Conjugates the given quaternion.

Definition at line 266 of file shz_quat.hpp.

266 {
267 *this = conjugated();
268 }
quat conjugated() const noexcept
Returns a quaternion that is the conjugate of the given quaternion.
Definition shz_quat.hpp:261

◆ inverse()

quat shz::quat::inverse ( ) const
inlinenoexcept

Returns the inverse of the given quaternion.

Definition at line 271 of file shz_quat.hpp.

271 {
272 return shz_quat_inv(*this);
273 }
shz_quat_t shz_quat_inv(shz_quat_t quat) SHZ_NOEXCEPT
Returns the inverse of the given quaternion.

◆ invert()

void shz::quat::invert ( )
inlinenoexcept

Inverts the given quaternion.

Definition at line 276 of file shz_quat.hpp.

276 {
277 *this = inverse();
278 }
quat inverse() const noexcept
Returns the inverse of the given quaternion.
Definition shz_quat.hpp:271

◆ negated()

quat shz::quat::negated ( ) const
inlinenoexcept

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

Definition at line 281 of file shz_quat.hpp.

281 {
282 return shz_quat_neg(*this);
283 }
shz_quat_t shz_quat_neg(shz_quat_t quat) SHZ_NOEXCEPT
Returns the negation of the given quaternion.

◆ negate()

void shz::quat::negate ( )
inlinenoexcept

Negates the components of the given quaternion.

Definition at line 286 of file shz_quat.hpp.

286 {
287 *this = negated();
288 }
quat negated() const noexcept
Returns a new quaternion whose components are the negated values of the given quaternion.
Definition shz_quat.hpp:281

◆ add()

quat shz::quat::add ( const quat & rhs) const
inlinenoexcept

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

Definition at line 298 of file shz_quat.hpp.

298 {
299 return shz_quat_add(*this, rhs);
300 }
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.

◆ sub()

quat shz::quat::sub ( const quat & rhs) const
inlinenoexcept

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

Definition at line 303 of file shz_quat.hpp.

303 {
304 return shz_quat_sub(*this, rhs);
305 }
shz_quat_t shz_quat_sub(shz_quat_t q, shz_quat_t p) SHZ_NOEXCEPT
Returns the quaternion produced from subtracting each component of quaternion p from quaterion q.

◆ scaled()

quat shz::quat::scaled ( float s) const
inlinenoexcept

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

Definition at line 308 of file shz_quat.hpp.

308 {
309 return shz_quat_scale(*this, s);
310 }
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.

◆ scale()

void shz::quat::scale ( float s)
inlinenoexcept

Multiplies each component of the given quaternion by s.

Definition at line 313 of file shz_quat.hpp.

313 {
314 *this = scaled(s);
315 }
quat scaled(float s) const noexcept
Returns a new quaternion from scaling the given quaterion by s.
Definition shz_quat.hpp:308

◆ dot() [1/3]

float shz::quat::dot ( const quat & other) const
inlinenoexcept

Returns the dot product between the given quaternion and another.

Definition at line 318 of file shz_quat.hpp.

318 {
319 return shz_quat_dot(*this, other);
320 }
float shz_quat_dot(shz_quat_t q1, shz_quat_t q2) SHZ_NOEXCEPT
Returns the dot product of the two quaternions.

◆ dot() [2/3]

vec2 shz::quat::dot ( const quat & q1,
const quat & q2 ) const
inlinenoexcept

Returns the dot product of the given quaternion against two others.

Definition at line 323 of file shz_quat.hpp.

323 {
324 return shz_quat_dot2(*this, q1, q2);
325 }
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.

◆ dot() [3/3]

vec3 shz::quat::dot ( const quat & q1,
const quat & q2,
const quat & q3 ) const
inlinenoexcept

Returns the dot product of the given quaternion against three others.

Definition at line 328 of file shz_quat.hpp.

328 {
329 return shz_quat_dot3(*this, q1, q2, q3);
330 }
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.

◆ mult()

quat shz::quat::mult ( const quat & rhs) const
inlinenoexcept

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

Definition at line 333 of file shz_quat.hpp.

333 {
334 return shz_quat_mult(*this, rhs);
335 }
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.

◆ div()

quat shz::quat::div ( const quat & rhs) const
inlinenoexcept

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

Definition at line 338 of file shz_quat.hpp.

338 {
339 return shz_quat_div(*this, rhs);
340 }
shz_quat_t shz_quat_div(shz_quat_t q, shz_quat_t p) SHZ_NOEXCEPT
Divides quaternion p by quaternion q (multiplying by its inverse), returning the resulting quaternion...

◆ angle_between()

float shz::quat::angle_between ( const quat & p) const
inlinenoexcept

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

Definition at line 350 of file shz_quat.hpp.

350 {
351 return shz_quat_angle_between(*this, p);
352 }
float shz_quat_angle_between(shz_quat_t q, shz_quat_t p) SHZ_NOEXCEPT
Returns the angle in radians between the rotations represented by quaternions q and p.

◆ rotate_towards()

quat shz::quat::rotate_towards ( const quat & to,
float max_angle ) const
inlinenoexcept

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

Definition at line 355 of file shz_quat.hpp.

355 {
356 return shz_quat_rotate_towards(*this, to, max_angle);
357 }
shz_quat_t shz_quat_rotate_towards(shz_quat_t from, shz_quat_t to, float max_angle) SHZ_NOEXCEPT
Rotates quaternion from towards quaternion to by at most max_angle radians.

◆ transform()

vec3 shz::quat::transform ( const vec3 & in) const
inlinenoexcept

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

Definition at line 367 of file shz_quat.hpp.

367 {
368 return shz_quat_transform_vec3(*this, in);
369 }
shz_vec3_t shz_quat_transform_vec3(shz_quat_t q, shz_vec3_t v) SHZ_NOEXCEPT
Rotates a vector by the given quaternion.

◆ operator-()

quat shz::quat::operator- ( ) const
inlinenoexcept

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

Definition at line 374 of file shz_quat.hpp.

374 {
375 return negated();
376 }

◆ operator+=()

quat shz::quat::operator+= ( const quat & rhs)
inlinenoexcept

Adds and accumulates rhs onto the given quaternion.

Definition at line 379 of file shz_quat.hpp.

379 {
380 return *this = add(rhs);
381 }
quat add(const quat &rhs) const noexcept
Returns a new quaternion from adding the given quaterion to rhs.
Definition shz_quat.hpp:298

◆ operator-=()

quat shz::quat::operator-= ( const quat & rhs)
inlinenoexcept

Subtracts rhs from the given quaternion.

Definition at line 384 of file shz_quat.hpp.

384 {
385 return *this = sub(rhs);
386 }
quat sub(const quat &rhs) const noexcept
Returns a new quaternion from adding rhs from the given quaternion.
Definition shz_quat.hpp:303

◆ operator*=() [1/2]

quat shz::quat::operator*= ( const quat & rhs)
inlinenoexcept

Multiplies and accumulates rhs into the given quaternion.

Definition at line 389 of file shz_quat.hpp.

389 {
390 return *this = mult(rhs);
391 }
quat mult(const quat &rhs) const noexcept
Returns a new quaterion from multiplying the given quaternion by another.
Definition shz_quat.hpp:333

◆ operator/=() [1/2]

quat shz::quat::operator/= ( const quat & rhs)
inlinenoexcept

Divides the given quaternion by rhs.

Definition at line 394 of file shz_quat.hpp.

394 {
395 return *this = div(rhs);
396 }
quat div(const quat &rhs) const noexcept
Returns a new quaterion from dividing the given quaternion by another (or multiplying the given quate...
Definition shz_quat.hpp:338

◆ operator*=() [2/2]

quat shz::quat::operator*= ( float rhs)
inlinenoexcept

Multiplies and accumulates each component of the given quaternion by rhs.

Definition at line 399 of file shz_quat.hpp.

399 {
400 scale(rhs);
401 return *this;
402 }
void scale(float s) noexcept
Multiplies each component of the given quaternion by s.
Definition shz_quat.hpp:313

◆ operator/=() [2/2]

quat shz::quat::operator/= ( float rhs)
inlinenoexcept

Divides each component of the given quaternion by rhs.

Definition at line 405 of file shz_quat.hpp.

405 {
406 scale(shz_invf(rhs));
407 return *this;
408 }
float shz_invf(float x) SHZ_NOEXCEPT
Takes the inverse of x using a slighty faster approximation than doing a full division,...

Friends And Related Symbol Documentation

◆ operator==

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

Overloaded comparison operator, checks for quaternion equality.

Definition at line 158 of file shz_quat.hpp.

158 {
159 return shz_quat_equal(lhs, rhs);
160 }
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...

The documentation for this struct was generated from the following file: