libnds
Macros | Functions
math.h File Reference

hardware coprocessor math instructions. More...

#include "nds/ndstypes.h"

Macros

#define f32tofloat(n)   (((float)(n)) / (float)(1<<12))
 convert f32 to float
 
#define f32toint(n)   ((n) / (1 << 12))
 convert f32 to int
 
#define floattof32(n)   ((int)((n) * (1 << 12)))
 convert float to f32
 
#define inttof32(n)   ((n) * (1 << 12))
 convert int to f32
 

Functions

static void crossf32 (int32 *a, int32 *b, int32 *result)
 20.12 fixed point cross product function result = AxB More...
 
static int32 div32 (int32 num, int32 den)
 integer divide More...
 
static int32 div64 (int64 num, int32 den)
 integer 64 bit divide More...
 
static int32 divf32 (int32 num, int32 den)
 Fixed point divide. More...
 
static int32 dotf32 (int32 *a, int32 *b)
 20.12 fixed point dot product function result = A dot B More...
 
static int32 mod32 (int32 num, int32 den)
 integer modulous More...
 
static int32 mod64 (int64 num, int32 den)
 integer 64 bit modulous More...
 
static int32 mulf32 (int32 a, int32 b)
 Fixed point multiply. More...
 
static void normalizef32 (int32 *a)
 20.12 fixed point normalize function A = A / |A| More...
 
static u32 sqrt32 (int a)
 integer sqrt More...
 
static u32 sqrt64 (long long a)
 integer sqrt More...
 
static int32 sqrtf32 (int32 a)
 Fixed point sqrt. More...
 

Detailed Description

hardware coprocessor math instructions.

Function Documentation

static void crossf32 ( int32 a,
int32 b,
int32 result 
)
inlinestatic

20.12 fixed point cross product function result = AxB

Parameters
apointer to fixed 3x3 matrix
bpointer to fixed 3x3 matrix
resultpointer to fixed 3x3 matrix Cross product
x = Ay * Bz - By * Az
y = Az * Bx - Bz * Ax
z = Ax * By - Bx * Ay
static int32 div32 ( int32  num,
int32  den 
)
inlinestatic

integer divide

Parameters
numnumerator
dendenominator
Returns
returns 32 bit integer result
static int32 div64 ( int64  num,
int32  den 
)
inlinestatic

integer 64 bit divide

Parameters
num64 bit numerator
den32 bit denominator
Returns
returns 32 bit integer result
static int32 divf32 ( int32  num,
int32  den 
)
inlinestatic

Fixed point divide.

Parameters
numTakes 20.12 numerator.
denTakes 20.12 denominator.
Returns
returns 20.12 result.
static int32 dotf32 ( int32 a,
int32 b 
)
inlinestatic

20.12 fixed point dot product function result = A dot B

Parameters
apointer to fixed 3x3 matrix
bpointer to fixed 3x3 matrix
Returns
32 bit integer result Dot Product result = Ax * Bx + Ay * By + Az * Bz
static int32 mod32 ( int32  num,
int32  den 
)
inlinestatic

integer modulous

Parameters
numnumerator
dendenominator
Returns
returns 32 bit integer remainder
static int32 mod64 ( int64  num,
int32  den 
)
inlinestatic

integer 64 bit modulous

Parameters
num64 bit numerator
den32 bit denominator
Returns
returns 32 bit integer remainder
static int32 mulf32 ( int32  a,
int32  b 
)
inlinestatic

Fixed point multiply.

Parameters
aTakes 20.12
bTakes 20.12
Returns
returns 20.12 result
static void normalizef32 ( int32 a)
inlinestatic

20.12 fixed point normalize function A = A / |A|

Parameters
apointer to fixed 3x3 matrix Normalize
Ax = Ax / mag
Ay = Ay / mag
Az = Az / mag
static u32 sqrt32 ( int  a)
inlinestatic

integer sqrt

Parameters
a32 bit integer argument
Returns
returns 32 bit integer result
static u32 sqrt64 ( long long  a)
inlinestatic

integer sqrt

Parameters
a64 bit integer argument
Returns
returns 32 bit integer result
static int32 sqrtf32 ( int32  a)
inlinestatic

Fixed point sqrt.

Parameters
aTakes 20.12
Returns
returns 20.12 result