Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
Loading...
Searching...
No Matches
quaternions.h File Reference

Go to the source code of this file.

Functions

float rsqrtf (float x)
 Perform a fast, approximate reciprocal square root.
 
float mathsqrtf (float x)
 Perform a fast, approximate square root.
 
void mathEulerToQuat (float *q, const float *euler)
 convert euler angles (in radians) to a quaternion.
 
void mathQuatApply (float *qout, const float *q1, const float *q2)
 Rotate one quaternion by another (and do not normalize)
 
void mathQuatNormalize (float *qout, const float *qin)
 Normalize a quaternion.
 
void mathCrossProduct (float *p, const float *a, const float *b)
 Perform a 3D cross product.
 
void mathRotateVectorByInverseOfQuaternion (float *pout, const float *q, const float *p)
 Rotate a 3D vector by the inverse of a quaternion.
 
void mathRotateVectorByQuaternion (float *pout, const float *q, const float *p)
 Rotate a 3D vector by a quaternion.
 
void mathComputeQuaternionDeltaBetweenQuaternions (float *qOut, const float *q1, const float *b)
 Compute the difference between two quaternions.
 
void mathQuatFromTwoVectors (float *qOut, const float *v1, const float *v2)
 Compute the quaterntion rotation between two vectors, from v1 to v2.
 

Function Documentation

◆ rsqrtf()

float rsqrtf ( float x)

Perform a fast, approximate reciprocal square root.

Parameters
xThe number to take a recriprocal square root of.
Returns
approximately 1/sqrt(x)

◆ mathsqrtf()

float mathsqrtf ( float x)

Perform a fast, approximate square root.

Parameters
xThe number to take a square root of.
Returns
approximately sqrt(x) (but is much faster)

◆ mathEulerToQuat()

void mathEulerToQuat ( float * q,
const float * euler )

convert euler angles (in radians) to a quaternion.

Parameters
qPointer to the wxyz quat (float[4]) to be written.
eulerPointer to a float[3] of euler angles.

◆ mathQuatApply()

void mathQuatApply ( float * qout,
const float * q1,
const float * q2 )

Rotate one quaternion by another (and do not normalize)

Parameters
qoutPointer to the wxyz quat (float[4]) to be written.
q1First quaternion to be rotated.
q2Quaternion to rotate q1 by.

◆ mathQuatNormalize()

void mathQuatNormalize ( float * qout,
const float * qin )

Normalize a quaternion.

Parameters
qoutPointer to the wxyz quat (float[4]) to be written.
qinPointer to the quaterion to normalize.

◆ mathCrossProduct()

void mathCrossProduct ( float * p,
const float * a,
const float * b )

Perform a 3D cross product.

Parameters
pPointer to the float[3] output of the cross product (p = a x b)
aPointer to the float[3] of the cross product a vector.
bPointer to the float[3] of the cross product b vector.

◆ mathRotateVectorByInverseOfQuaternion()

void mathRotateVectorByInverseOfQuaternion ( float * pout,
const float * q,
const float * p )

Rotate a 3D vector by the inverse of a quaternion.

Parameters
poutPointer to the float[3] output of the antirotation.
qPointer to the wxyz quaternion (float[4]) opposite of the rotation.
pPointer to the float[3] of the vector to antirotates.

◆ mathRotateVectorByQuaternion()

void mathRotateVectorByQuaternion ( float * pout,
const float * q,
const float * p )

Rotate a 3D vector by a quaternion.

Parameters
poutPointer to the float[3] output of the rotation
qPointer to the wxyz quaternion (float[4]) of the rotation.
pPointer to the float[3] of the vector to rotates.

◆ mathComputeQuaternionDeltaBetweenQuaternions()

void mathComputeQuaternionDeltaBetweenQuaternions ( float * qOut,
const float * qFrom,
const float * qTo )

Compute the difference between two quaternions.

Parameters
qOutPointer to the float[4] (wxyz) output of the rotation between qFrom and qTo.
qFromis the Quaterntion that you are rotating FROM
qTois the Quaternion that you are rotating TO

◆ mathQuatFromTwoVectors()

void mathQuatFromTwoVectors ( float * qOut,
const float * v1,
const float * v2 )

Compute the quaterntion rotation between two vectors, from v1 to v2.

Parameters
qOutPointer to the float[4] (wxyz) output of the rotation defined by v1 to v2
v1is the vector you are rotating FROM. THIS MUST BE NORMALIZED.
v2is the vector you are rotating TO. THIS MUST BE NORMALIZED.