wavelength 1.0.0
Loading...
Searching...
No Matches
Rnd Namespace Reference

Classes

struct  Ray
 Line in a plane, given as a point on it and its direction. More...

Functions

void MakeRotMatrix (const Quat &quat, float *pMat3Rows)
 Convert a rotation quaternion to a rotation matrix.
Vector2 Intersect (const Ray &first, const Ray &second)
 Find where two lines in a plane cross.
void MakeRotMatrix (const float *pAngles, float *pMat3Rows)
 Build a rotation matrix from three Euler angles.
void Scale (const float *pScale, const float *pMat3Rows, float *pOut)
 Scale each row of a rotation matrix by one component of a vector.
void Add (const Vector2 &a, const Vector2 &b, Vector2 &out)
 Add two two-component vectors.
void Normalize (const Vector2 &v, Vector2 &out)
 Scale a two-component vector to unit length.
float Length (const Vector2 &v)
 Report the length of a two-component vector.
void Add (const float *pA, const float *pB, float *pOut)
 Add two three-component vectors.
void Subtract (const float *pA, const float *pB, float *pOut)
 Subtract one three-component vector from another.

Function Documentation

◆ MakeRotMatrix() [1/2]

void Rnd::MakeRotMatrix ( const Quat & quat,
float * pMat3Rows )

Convert a rotation quaternion to a rotation matrix.

The result is the transpose of the usual column-vector rotation, because this engine transforms row vectors. Only nine of the twelve words are written, and the fourth word of each row is untouched.

Parameters
quatThe rotation, treated as unit length.
pMat3RowsReceives the rotation, three rows of four floats.
Ghidra address:
NTSC-U/C: 0x00292ce0
Ghidra address:
PAL: 0x0029c6a8

◆ Intersect()

Vector2 Rnd::Intersect ( const Ray & first,
const Ray & second )

Find where two lines in a plane cross.

Parallel lines report the point of the first line.

Parameters
firstThe first line.
secondThe second line.
Returns
The crossing point.
Ghidra address:
NTSC-U/C: 0x002907f0
Ghidra address:
PAL: 0x0029a1b8

◆ MakeRotMatrix() [2/2]

void Rnd::MakeRotMatrix ( const float * pAngles,
float * pMat3Rows )

Build a rotation matrix from three Euler angles.

The product is Ry * Rx * Rz, with each factor a rotation about one axis by the matching component and every factor written for row vectors. Mat34DecomposeEulerScale() inverts the same composition and EulerAnglesToQuat() reproduces it as a quaternion. Only nine of the twelve words are written, and the fourth word of each row is untouched. The sines and cosines come from SinApprox().

Parameters
pAnglesThe three angles in radians, ordered X, Y, and Z.
pMat3RowsReceives the rotation, three rows of four floats.
Ghidra address:
NTSC-U/C: 0x00292b38
Ghidra address:
PAL: 0x0029c500

◆ Scale()

void Rnd::Scale ( const float * pScale,
const float * pMat3Rows,
float * pOut )

Scale each row of a rotation matrix by one component of a vector.

Row zero takes the first component, row one the second, and row two the third. This is how a non-uniform scale is folded into a basis. Only nine of the twelve words are written, and the fourth word of each row is untouched.

Parameters
pScaleThe three scales.
pMat3RowsThe basis to scale, three rows of four floats.
pOutReceives the scaled basis, and may alias pMat3Rows.

◆ Add() [1/2]

void Rnd::Add ( const Vector2 & a,
const Vector2 & b,
Vector2 & out )

Add two two-component vectors.

The destination may alias either source because both loads precede both stores. The routine reads y before x and stores y before x, with the x store in the return delay slot.

Parameters
aThe first vector.
bThe second vector.
outReceives a plus b, and may alias either input.

◆ Normalize()

void Rnd::Normalize ( const Vector2 & v,
Vector2 & out )

Scale a two-component vector to unit length.

The zero vector yields the zero vector rather than a division by zero.

Parameters
vThe vector.
outReceives the unit vector.

◆ Length()

float Rnd::Length ( const Vector2 & v)

Report the length of a two-component vector.

Parameters
vThe vector.
Returns
The length.

◆ Add() [2/2]

void Rnd::Add ( const float * pA,
const float * pB,
float * pOut )

Add two three-component vectors.

Writes three components and does not touch the fourth word of the destination. The two inputs arrive in $a0 and $a1 and the destination in $a2.

Parameters
pAThe first vector.
pBThe second vector.
pOutReceives pA plus pB, and may alias either input.

◆ Subtract()

void Rnd::Subtract ( const float * pA,
const float * pB,
float * pOut )

Subtract one three-component vector from another.

Writes three components and does not touch the fourth word of the destination. The minuend arrives in $a0, the subtrahend in $a1, and the destination in $a2.

Parameters
pAThe vector subtracted from.
pBThe vector to subtract.
pOutReceives pA less pB, and may alias either input.