KallistiOS  ##version##
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Macros | Functions
fmath.h File Reference

Inline functions for the DC's special math instructions. More...

#include <sys/cdefs.h>
#include <arch/types.h>
#include <dc/fmath_base.h>

Go to the source code of this file.

Macros

#define __FMINLINE   static
 

Functions

__FMINLINE float fipr (float x, float y, float z, float w, float a, float b, float c, float d)
 Floating point inner product. More...
 
__FMINLINE float fipr_magnitude_sqr (float x, float y, float z, float w)
 Floating point inner product w/self (square of vector magnitude) More...
 
__FMINLINE float fsin (float r)
 Floating point sine. More...
 
__FMINLINE float fcos (float r)
 Floating point cosine. More...
 
__FMINLINE float ftan (float r)
 Floating point tangent. More...
 
__FMINLINE float fisin (int d)
 Integer sine. More...
 
__FMINLINE float ficos (int d)
 Integer cosine. More...
 
__FMINLINE float fitan (int d)
 Integer tangent. More...
 
__FMINLINE float fsqrt (float f)
 Floating point square root. More...
 
__FMINLINE float frsqrt (float f)
 
__FMINLINE void fsincos (float f, float *s, float *c)
 Calculate the sine and cosine of a value in degrees. More...
 
__FMINLINE void fsincosr (float f, float *s, float *c)
 Calculate the sine and cosine of a value in radians. More...
 
__FMINLINE uint32 pvr_pack_bump (float h, float t, float q)
 Calculate the offset color value for a set of bumpmap parameters. More...
 

Detailed Description

Inline functions for the DC's special math instructions.

Author
Andrew Kieschnick
Lawrence Sebald

Macro Definition Documentation

#define __FMINLINE   static

Function Documentation

__FMINLINE float fcos ( float  r)

Floating point cosine.

Parameters
ra floating point number between 0 and 2*PI
Returns
cos(r), where r is [0..2*PI]
__FMINLINE float ficos ( int  d)

Integer cosine.

Parameters
dan integer between 0 and 65535
Returns
cos(d), where d is [0..65535]
__FMINLINE float fipr ( float  x,
float  y,
float  z,
float  w,
float  a,
float  b,
float  c,
float  d 
)

Floating point inner product.

Returns
v1 dot v2 (inner product)
__FMINLINE float fipr_magnitude_sqr ( float  x,
float  y,
float  z,
float  w 
)

Floating point inner product w/self (square of vector magnitude)

Returns
v1 dot v1 (square of magnitude)
__FMINLINE float fisin ( int  d)

Integer sine.

Parameters
dan integer between 0 and 65535
Returns
sin(d), where d is [0..65535]
__FMINLINE float fitan ( int  d)

Integer tangent.

Parameters
dan integer between 0 and 65535
Returns
tan(d), where d is [0..65535]
__FMINLINE float frsqrt ( float  f)
Returns
1.0f / sqrt(f)
__FMINLINE float fsin ( float  r)

Floating point sine.

Parameters
ra floating point number between 0 and 2*PI
Returns
sin(r), where r is [0..2*PI]
__FMINLINE void fsincos ( float  f,
float *  s,
float *  c 
)

Calculate the sine and cosine of a value in degrees.

This function uses the fsca instruction to calculate an approximation of the sine and cosine of the input value.

Parameters
fThe value to calculate the sine and cosine of.
sStorage for the returned sine value.
cStorage for the returned cosine value.
__FMINLINE void fsincosr ( float  f,
float *  s,
float *  c 
)

Calculate the sine and cosine of a value in radians.

This function uses the fsca instruction to calculate an approximation of the sine and cosine of the input value.

Parameters
fThe value to calculate the sine and cosine of.
sStorage for the returned sine value.
cStorage for the returned cosine value.
__FMINLINE float fsqrt ( float  f)

Floating point square root.

Returns
sqrt(f)
__FMINLINE float ftan ( float  r)

Floating point tangent.

Parameters
ra floating point number between 0 and 2*PI
Returns
tan(r), where r is [0..2*PI]
__FMINLINE uint32 pvr_pack_bump ( float  h,
float  t,
float  q 
)

Calculate the offset color value for a set of bumpmap parameters.

This function calculates the value to be placed into the oargb value for the use of bumpmapping on a polygon. The angles specified should be expressed in radians and within the limits specified for the individual parameter.

Parameters
hWeighting value in the range [0, 1] for how defined the bumpiness of the surface should be.
tSpherical elevation angle in the range [0, pi/2] between the surface and the lighting source. A value of pi/2 implies that the light is directly overhead.
qSpherical rotation angle in the range [0, 2*pi] between the surface and the lighting source.
Returns
32-bit packed value to be used as an offset color on the surface to be bump mapped.
Note
For more information about how bumpmapping on the PVR works, refer to US Patent 6,819,319, which describes the algorithm implemented in the hardware (specifically look at Figures 2 and 3, along with the description in the Detailed Description section).
Thanks to Fredrik Ehnbom for figuring this stuff out and posting it to the mailing list back in 2005!

References F_PI.