wavelength 1.0.0
Loading...
Searching...
No Matches
quaternion.h File Reference
#include "os/prnstream.h"
Include dependency graph for quaternion.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Quat
 Rotation quaternion, stored as the vector part followed by the scalar part. More...

Namespaces

namespace  Rnd

Functions

PrnStream & operator<< (PrnStream &stream, const Quat &quat)
 Write a quaternion as x: y: z: w:.
Quat EulerAnglesToQuat (const float *pAngles)
 Build a rotation quaternion from three Euler angles.
void QuatSlerp (const Quat &from, const Quat &to, Quat &out, float flT)
 Interpolate between two rotation quaternions along the shorter arc.
void Rnd::MakeRotMatrix (const Quat &quat, float *pMat3Rows)
 Convert a rotation quaternion to a rotation matrix.
void Mat33ExtractScale (const float *pMat3Rows, float *pScale)
 Report the scale each basis row carries.

Function Documentation

◆ operator<<()

PrnStream & operator<< ( PrnStream & stream,
const Quat & quat )

Write a quaternion as x: y: z: w:.

Parameters
streamThe stream to write to.
quatThe quaternion.
Returns
The stream.
Ghidra address:
NTSC-U/C: 0x00292d88
Ghidra address:
PAL: 0x0029c750

◆ EulerAnglesToQuat()

Quat EulerAnglesToQuat ( const float * pAngles)

Build a rotation quaternion from three Euler angles.

The composition is the same one Rnd::MakeRotMatrix() produces from three angles. That is, the product is qz * qx * qy, with each factor a rotation about one axis by the matching component. The sines and cosines come from SinApprox().

Parameters
pAnglesThe three angles in radians, ordered X, Y, and Z.
Returns
The quaternion.
Ghidra address:
NTSC-U/C: 0x002925d8
Ghidra address:
PAL: 0x0029bfa0

◆ QuatSlerp()

void QuatSlerp ( const Quat & from,
const Quat & to,
Quat & out,
float flT )

Interpolate between two rotation quaternions along the shorter arc.

A negative dot product flips the second quaternion. The interpolation therefore never takes the long way round. Both endpoint values of the parameter are special cased and copy an endpoint verbatim. Two inputs whose dot product is within 1e-5 of one fall back to a component-wise linear blend. The sines come from SinApprox().

Parameters
fromThe rotation at a parameter of zero.
toThe rotation at a parameter of one.
outReceives the interpolation.
flTThe interpolation parameter.
Ghidra address:
NTSC-U/C: 0x00292970
Ghidra address:
PAL: 0x0029c338

◆ Mat33ExtractScale()

void Mat33ExtractScale ( const float * pMat3Rows,
float * pScale )

Report the scale each basis row carries.

Each scale is the length of its row. The Z scale is negated unless the dot product of the Z row with the cross product of the X and Y rows is positive.

Parameters
pMat3RowsThe basis, three rows of four floats.
pScaleReceives the three scales.
Ghidra address:
NTSC-U/C: 0x002924f0
Ghidra address:
PAL: 0x0029beb8