Main Page   Modules   Data Structures   File List   Globals  

msh_math.h File Reference

Math functions. More...


Defines

#define BOUNDS(num, min, max)   ((num) < (min) ? (min) : ((num) > (max) ? (max) : (num)))
#define math_sin(deg)   ((deg) >= 0 ? _sin_table[deg] : -_sin_table[-(deg)])
#define math_cos(deg)   ((deg) >= 0 ? _cos_table[deg] : _cos_table[-(deg)])

Functions

fixed math_atan2 (fixed y, fixed x)
void math_fastdiv (s32 n, s32 d, s32 *result, s32 *remainder)
void math_rand_set_seed (u32 seed)
u32 math_rand_get_seed ()
u16 math_rand (u16 max)


Detailed Description


Define Documentation

#define BOUNDS num,
min,
max       ((num) < (min) ? (min) : ((num) > (max) ? (max) : (num)))
 

Returns num if it is in between min and max, otherwise num is clipped to min or max

#define math_sin deg       ((deg) >= 0 ? _sin_table[deg] : -_sin_table[-(deg)])
 

Parameters:
deg  s16 [-359..359] Angle in degrees
Returns:
fixed Sine of angle

#define math_cos deg       ((deg) >= 0 ? _cos_table[deg] : _cos_table[-(deg)])
 

Parameters:
deg  s16 [-359..359] Angle in degrees
Returns:
fixed Cosine of angle


Function Documentation

fixed math_atan2 fixed    y,
fixed    x
 

Parameters:
y  Y
x  X
Returns:
Result

void math_fastdiv s32    n,
s32    d,
s32 *    result,
s32 *    remainder
 

Parameters:
n  Numerator
d  Denomenator
result  Result
remainder  Remainder
Uses the GBA BIOS divide function. The result and remainder get placed in the addresses specified.
eg. math_fastdiv(129, 10, &result, &remainder);

void math_rand_set_seed u32    seed
 

Parameters:
seed  Start seed value
Sets the starting seed value for the math_rand() function.
A good way to set this is to run a timer and then use the value of the timer when the user presses a button.
This only needs to be set once.

u32 math_rand_get_seed  
 

Returns:
Seed value
This returns the current random seed value.
This value will change each time you call math_rand().

u16 math_rand u16    max
 

Parameters:
max  Maximum number
Returns:
[0..max] Random number
Returns a random from 0 to max.
Eg. math_rand(255) will return a random number from 0 to 255.
math_rand_set_seed() should be called before using this.


Generated on Wed May 19 21:45:08 2004 for Mushroom GBALib by doxygen 1.2.18