SH4ZAM! 0.1.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+= (quat rhs) noexcept
 
quat operator-= (quat rhs) noexcept
 
quat operator*= (quat rhs) noexcept
 
quat operator/= (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 (quat rhs) const noexcept
 
quat sub (quat rhs) const noexcept
 
quat scaled (float s) const noexcept
 
void scale (float s) noexcept
 
float dot (quat other) const noexcept
 
vec2 dot (quat q1, quat q2) const noexcept
 
vec3 dot (quat q1, quat q2, quat q3) const noexcept
 
quat mult (quat rhs) const noexcept
 
quat div (quat rhs) const noexcept
 
Miscellaneous

Other types of quaternion operations.

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

Routines for applying quaternion transforms.

vec3 transform (vec3 in) const noexcept
 

Static Public Attributes

static constexpr float slerp_phi_epsilon
 

Friends

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

Initialization

Routines for creating and initializing quaternions.

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

shz::quat::quat ( )
defaultnoexcept

Default constructor: does nothing.

◆ quat() [2/3]

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 51 of file shz_quat.hpp.

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

◆ quat() [3/3]

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

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

Definition at line 55 of file shz_quat.hpp.

55 :
56 shz_quat_t(q) {}

Member Function Documentation

◆ identity()

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

Returns an identity quaternion.

Definition at line 59 of file shz_quat.hpp.

59 {
60 return shz_quat_identity();
61 }
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 64 of file shz_quat.hpp.

64 {
65 return shz_quat_from_angles_xyz(x, y, z);
66 }
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 ( vec3 axis,
float angle )
inlinestaticnoexcept

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

Definition at line 69 of file shz_quat.hpp.

69 {
71 }
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:158
vec3 axis() const noexcept
Returns the axis of rotation represented by the given quaternion.
Definition shz_quat.hpp:163

◆ from_look_axis()

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

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

Definition at line 74 of file shz_quat.hpp.

74 {
75 return shz_quat_from_look_axis(forward, up);
76 }
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 ( vec3 start,
vec3 end )
inlinestaticnoexcept

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

Definition at line 79 of file shz_quat.hpp.

79 {
80 return shz_quat_from_rotated_axis(start, end);
81 }
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 ( quat q,
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 84 of file shz_quat.hpp.

84 {
85 return shz_quat_lerp(q, p, t);
86 }
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 ( quat q,
quat p,
float t )
inlinestaticnoexcept

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

Definition at line 89 of file shz_quat.hpp.

89 {
90 return shz_quat_nlerp(q, p, t);
91 }
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 ( quat q,
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 94 of file shz_quat.hpp.

94 {
95 return shz_quat_slerp(q, p, t);
96 }
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 ( quat q1,
quat q2,
quat s1,
quat s2,
float t )
inlinestaticnoexcept

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

Definition at line 99 of file shz_quat.hpp.

99 {
100 return shz_quat_squad(q1, q2, s1, s2, t);
101 }
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 158 of file shz_quat.hpp.

158 {
159 return shz_quat_angle(*this);
160 }
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 163 of file shz_quat.hpp.

163 {
164 return shz_quat_axis(*this);
165 }
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 168 of file shz_quat.hpp.

168 {
169 return shz_quat_angle_x(*this);
170 }
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 173 of file shz_quat.hpp.

173 {
174 return shz_quat_angle_y(*this);
175 }
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 178 of file shz_quat.hpp.

178 {
179 return shz_quat_angle_z(*this);
180 }
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 183 of file shz_quat.hpp.

183 {
184 return shz_quat_magnitude_sqr(*this);
185 }
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 188 of file shz_quat.hpp.

188 {
189 return shz_quat_magnitude(*this);
190 }
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 193 of file shz_quat.hpp.

193 {
194 return shz_quat_magnitude_inv(*this);
195 }
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 205 of file shz_quat.hpp.

205 {
206 return shz_quat_to_angles_xyz(*this);
207 }
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 210 of file shz_quat.hpp.

210 {
212 }
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 215 of file shz_quat.hpp.

215 {
216 std::pair<vec3, float> aa;
217 shz_quat_to_axis_angle(*this, &std::get<0>(aa), &std::get<1>(aa));
218 return aa;
219 }

◆ normalized()

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

Returns the given quaternion as a unit quaternion.

Definition at line 229 of file shz_quat.hpp.

229 {
230 return shz_quat_normalize(*this);
231 }
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 234 of file shz_quat.hpp.

234 {
235 *this = normalized();
236 }
quat normalized() const noexcept
Returns the given quaternion as a unit quaternion.
Definition shz_quat.hpp:229

◆ 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 239 of file shz_quat.hpp.

239 {
240 return shz_quat_normalize_safe(*this);
241 }
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 244 of file shz_quat.hpp.

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

◆ conjugated()

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

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

Definition at line 249 of file shz_quat.hpp.

249 {
250 return shz_quat_conjugate(*this);
251 }
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 254 of file shz_quat.hpp.

254 {
255 *this = conjugated();
256 }
quat conjugated() const noexcept
Returns a quaternion that is the conjugate of the given quaternion.
Definition shz_quat.hpp:249

◆ inverse()

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

Returns the inverse of the given quaternion.

Definition at line 259 of file shz_quat.hpp.

259 {
260 return shz_quat_inv(*this);
261 }
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 264 of file shz_quat.hpp.

264 {
265 *this = inverse();
266 }
quat inverse() const noexcept
Returns the inverse of the given quaternion.
Definition shz_quat.hpp:259

◆ negated()

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

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

Definition at line 269 of file shz_quat.hpp.

269 {
270 return shz_quat_neg(*this);
271 }
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 274 of file shz_quat.hpp.

274 {
275 *this = negated();
276 }
quat negated() const noexcept
Returns a new quaternion whose components are the negated values of the given quaternion.
Definition shz_quat.hpp:269

◆ add()

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

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

Definition at line 286 of file shz_quat.hpp.

286 {
287 return shz_quat_add(*this, rhs);
288 }
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 ( quat rhs) const
inlinenoexcept

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

Definition at line 291 of file shz_quat.hpp.

291 {
292 return shz_quat_sub(*this, rhs);
293 }
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 296 of file shz_quat.hpp.

296 {
297 return shz_quat_scale(*this, s);
298 }
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 301 of file shz_quat.hpp.

301 {
302 *this = scaled(s);
303 }
quat scaled(float s) const noexcept
Returns a new quaternion from scaling the given quaterion by s.
Definition shz_quat.hpp:296

◆ dot() [1/3]

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

Returns the dot product between the given quaternion and another.

Definition at line 306 of file shz_quat.hpp.

306 {
307 return shz_quat_dot(*this, other);
308 }
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 ( quat q1,
quat q2 ) const
inlinenoexcept

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

Definition at line 311 of file shz_quat.hpp.

311 {
312 return shz_quat_dot2(*this, q1, q2);
313 }
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 ( quat q1,
quat q2,
quat q3 ) const
inlinenoexcept

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

Definition at line 316 of file shz_quat.hpp.

316 {
317 return shz_quat_dot3(*this, q1, q2, q3);
318 }
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 ( quat rhs) const
inlinenoexcept

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

Definition at line 321 of file shz_quat.hpp.

321 {
322 return shz_quat_mult(*this, rhs);
323 }
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 ( 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 326 of file shz_quat.hpp.

326 {
327 return shz_quat_div(*this, rhs);
328 }
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 ( quat p) const
inlinenoexcept

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

Definition at line 338 of file shz_quat.hpp.

338 {
339 return shz_quat_angle_between(*this, p);
340 }
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 ( shz_quat_t to,
float max_angle ) const
inlinenoexcept

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

Definition at line 343 of file shz_quat.hpp.

343 {
344 return shz_quat_rotate_towards(*this, to, max_angle);
345 }
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 ( vec3 in) const
inlinenoexcept

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

Definition at line 355 of file shz_quat.hpp.

355 {
356 return shz_quat_transform_vec3(*this, in);
357 }
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 362 of file shz_quat.hpp.

362 {
363 return negated();
364 }

◆ operator+=()

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

Adds and accumulates rhs onto the given quaternion.

Definition at line 367 of file shz_quat.hpp.

367 {
368 return *this = add(rhs);
369 }
quat add(quat rhs) const noexcept
Returns a new quaternion from adding the given quaterion to rhs.
Definition shz_quat.hpp:286

◆ operator-=()

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

Subtracts rhs from the given quaternion.

Definition at line 372 of file shz_quat.hpp.

372 {
373 return *this = sub(rhs);
374 }
quat sub(quat rhs) const noexcept
Returns a new quaternion from adding rhs from the given quaternion.
Definition shz_quat.hpp:291

◆ operator*=() [1/2]

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

Multiplies and accumulates rhs into the given quaternion.

Definition at line 377 of file shz_quat.hpp.

377 {
378 return *this = mult(rhs);
379 }
quat mult(quat rhs) const noexcept
Returns a new quaterion from multiplying the given quaternion by another.
Definition shz_quat.hpp:321

◆ operator/=() [1/2]

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

Divides the given quaternion by rhs.

Definition at line 382 of file shz_quat.hpp.

382 {
383 return *this = div(rhs);
384 }
quat div(quat rhs) const noexcept
Returns a new quaterion from dividing the given quaternion by another (or multiplying the given quate...
Definition shz_quat.hpp:326

◆ operator*=() [2/2]

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

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

Definition at line 387 of file shz_quat.hpp.

387 {
388 scale(rhs);
389 return *this;
390 }
void scale(float s) noexcept
Multiplies each component of the given quaternion by s.
Definition shz_quat.hpp:301

◆ operator/=() [2/2]

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

Divides each component of the given quaternion by rhs.

Definition at line 393 of file shz_quat.hpp.

393 {
394 scale(shz_invf(rhs));
395 return *this;
396 }
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== ( quat lhs,
quat rhs )
friend

Overloaded comparison operator, checks for quaternion equality.

Definition at line 146 of file shz_quat.hpp.

146 {
147 return shz_quat_equal(lhs, rhs);
148 }
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...

Field Documentation

◆ slerp_phi_epsilon

float shz::quat::slerp_phi_epsilon
staticconstexpr

Minimum epsilon for bothering to interpolate in shz::quat::slerp().

Definition at line 40 of file shz_quat.hpp.


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