resonance 1.0.1
Loading...
Searching...
No Matches
vector3.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Vector3
 Three-component vector, padded to a PlayStation 2 quadword. More...

Namespaces

namespace  Rnd
 The rendering engine.

Functions

void Rnd::Add (const float *pA, const float *pB, float *pOut)
 Add two three-component vectors.
void Rnd::Subtract (const float *pA, const float *pB, float *pOut)
 Subtract one three-component vector from another.
void Vec3Scale (const float *pSrc, float flScale, float *pOut)
 Multiply a three-component vector by a scalar.
void NegateVec3 (const float *pSrc, float *pOut)
 Negate a three-component vector.
void Vec3Normalize (const float *pSrc, float *pOut)
 Scale a three-component vector to unit length.
void CrossVec3 (const float *pA, const float *pB, float *pOut)
 Take the cross product of two three-component vectors.

Variables

constexpr int kVec3PaddingFloat = 3
 Index of the padding float that follows the three components of a quadword vector.

Function Documentation

◆ Vec3Scale()

void Vec3Scale ( const float * pSrc,
float flScale,
float * pOut )

Multiply a three-component vector by a scalar.

Writes three components and does not touch the fourth word of the destination. The source arrives in $a0, the destination in $a1, and the factor in $f12. Integer and float argument registers are allocated independently on this target. The declared position of the factor is therefore an inference from the destination-last order the other helpers here use, and the register evidence alone does not fix it.

Parameters
pSrcThe vector to scale.
flScaleThe factor to apply.
pOutReceives the product, and may alias pSrc.
Ghidra address:
NTSC-U/C: 0x0024ecd0
Ghidra address:
PAL: 0x002640f8

◆ NegateVec3()

void NegateVec3 ( const float * pSrc,
float * pOut )

Negate a three-component vector.

Writes three components and does not touch the fourth word of the destination.

Parameters
pSrcThe vector to negate.
pOutReceives the negation, and may alias pSrc.
Ghidra address:
NTSC-U/C: 0x00492458
Ghidra address:
PAL: 0x004d0308

◆ Vec3Normalize()

void Vec3Normalize ( const float * pSrc,
float * pOut )

Scale a three-component vector to unit length.

The vector unit takes the reciprocal square root of the dot of the first three components with themselves, then scales those three by it. Both the load and the store move a whole quadword. The fourth word of the destination therefore receives the fourth word of the source unchanged. A zero-length input is not guarded against.

Parameters
pSrcThe vector to normalise.
pOutReceives the unit vector, and may alias pSrc.
Ghidra address:
NTSC-U/C: 0x00476140
Ghidra address:
PAL: 0x004b3db8

◆ CrossVec3()

void CrossVec3 ( const float * pA,
const float * pB,
float * pOut )
inline

Take the cross product of two three-component vectors.

The image has no out-of-line copy. Every caller inlines the VU0 vopmula.xyz and vopmsub.xyz pair, which writes only the three components and therefore leaves the fourth word of pA in the result.

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

Variable Documentation

◆ kVec3PaddingFloat

int kVec3PaddingFloat = 3
constexpr

Index of the padding float that follows the three components of a quadword vector.