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

Functions

void fastNormVec (q24_8 *xp, q24_8 *yp)
 Quickly normalize a q24_8 vector, in-place.
 
vec_q24_8 fpvNorm (vec_q24_8 vec)
 Normalize and return a vector.
 
q24_8 fpvDot (vec_q24_8 a, vec_q24_8 b)
 Compute the dot product of two vectors.
 
q24_8 fpvSqMag (vec_q24_8 a)
 Compute the squared magnitude of a vector.
 
vec_q24_8 fpvAdd (vec_q24_8 a, vec_q24_8 b)
 Add two vectors.
 
vec_q24_8 fpvSub (vec_q24_8 a, vec_q24_8 b)
 Subtract two vectors.
 
vec_q24_8 fpvMulSc (vec_q24_8 vec, q24_8 scalar)
 Multiply a vector by a scalar.
 
vec_q24_8 fpvDivSc (vec_q24_8 vec, q24_8 scalar)
 Divide a vector by a scalar.
 
float fixToFloat (q24_8 fx)
 Convert a q24_8 to floating point.
 

Function Documentation

◆ fastNormVec()

void fastNormVec ( q24_8 * xp,
q24_8 * yp )

Quickly normalize a q24_8 vector, in-place.

Parameters
xpThe X component of the vector, normalized in-place
ypThe Y component of the vector, normalized in-place

◆ fpvNorm()

vec_q24_8 fpvNorm ( vec_q24_8 vec)

Normalize and return a vector.

Parameters
vecThe vector to normalize
Returns
The normalized vector

◆ fpvDot()

q24_8 fpvDot ( vec_q24_8 a,
vec_q24_8 b )

Compute the dot product of two vectors.

Parameters
aA vector to dot
bThe other vector to dot
Returns
The dot product of the two vectors

◆ fpvSqMag()

q24_8 fpvSqMag ( vec_q24_8 a)

Compute the squared magnitude of a vector.

Parameters
aThe vector to compute the squared magnitude of
Returns
The squared magnitude of the vector

◆ fpvAdd()

vec_q24_8 fpvAdd ( vec_q24_8 a,
vec_q24_8 b )

Add two vectors.

Parameters
aA vector to add
bThe other vector to add
Returns
The sum of the two input vectors

◆ fpvSub()

vec_q24_8 fpvSub ( vec_q24_8 a,
vec_q24_8 b )

Subtract two vectors.

Parameters
aA vector to subtract from
bThe other vector to subtract
Returns
The difference between the two input vectors

◆ fpvMulSc()

vec_q24_8 fpvMulSc ( vec_q24_8 vec,
q24_8 scalar )

Multiply a vector by a scalar.

Parameters
vecA vector multiply
scalarA scalar to multiply the vector by
Returns
The scaled vector

◆ fpvDivSc()

vec_q24_8 fpvDivSc ( vec_q24_8 vec,
q24_8 scalar )

Divide a vector by a scalar.

Parameters
vecA vector divide
scalarA scalar to divide the vector by
Returns
The scaled vector

◆ fixToFloat()

float fixToFloat ( q24_8 fx)

Convert a q24_8 to floating point.

Parameters
fxFixed point input
Returns
Floating point output