libnds
|
fixed point trig functions. Angle can be in the range of -32768 to More...
#include <nds/ndstypes.h>
Macros | |
#define | angleToDegrees(angle) ((angle) * 360 / DEGREES_IN_CIRCLE) |
converts an angle in the format used by libnds in the 360 degree format. | |
#define | DEGREES_IN_CIRCLE (1 << 15) |
number of degrees in a circle. | |
#define | degreesToAngle(degrees) ((degrees) * DEGREES_IN_CIRCLE / 360) |
convert an angle in 360 degree format to the format used by libnds. | |
#define | fixedToFloat(n, bits) (((float)(n)) / (float)(1<<(bits))) |
converts a fixed point number to a floating point number. More... | |
#define | fixedToInt(n, bits) ((int)((n)>>(bits))) |
convert a fixed point number to an integer. More... | |
#define | floatToFixed(n, bits) ((int)((n) * (float)(1<<(bits)))) |
converts a floating point number to a fixed point number. More... | |
#define | floorFixed(n, bits) ((int)((n) & ~(((1 << (bits)) - 1)))) |
removes the decimal part of a fixed point number. More... | |
#define | intToFixed(n, bits) ((int)((n)<<(bits))) |
converts an integer to a fixed point number. More... | |
Functions | |
s16 | acosLerp (s16 par) |
fixed point arccos More... | |
s16 | asinLerp (s16 par) |
fixed point arcsin More... | |
s16 | cosLerp (s16 angle) |
fixed point cosine More... | |
s16 | sinLerp (s16 angle) |
fixed point sine More... | |
s32 | tanLerp (s16 angle) |
fixed point tangent More... | |
fixed point trig functions. Angle can be in the range of -32768 to
angle = degreesToAngle(angleInDegrees);
or
angle = angleInDegrees * 32768 / 360;
This unit of measure is sometimes refered to as a binary radian (brad) or binary degree. It allows for more precise representation of angle and faster calculation as the DS has no floating point processor.
#define fixedToFloat | ( | n, | |
bits | |||
) | (((float)(n)) / (float)(1<<(bits))) |
converts a fixed point number to a floating point number.
n | the fixed point number to convert. |
bits | the number of bits used for the decimal part. |
#define fixedToInt | ( | n, | |
bits | |||
) | ((int)((n)>>(bits))) |
convert a fixed point number to an integer.
n | the number the number to convert. |
bits | the number of bits used for the decimal part. |
#define floatToFixed | ( | n, | |
bits | |||
) | ((int)((n) * (float)(1<<(bits)))) |
converts a floating point number to a fixed point number.
n | the floating point number to convert. |
bits | the number of bits used for the decimal part. |
#define floorFixed | ( | n, | |
bits | |||
) | ((int)((n) & ~(((1 << (bits)) - 1)))) |
removes the decimal part of a fixed point number.
n | the fixed point number. |
bits | the number of bits used for the decimal part. |
#define intToFixed | ( | n, | |
bits | |||
) | ((int)((n)<<(bits))) |
converts an integer to a fixed point number.
n | the integer to convert. |
bits | the number of bits used for the decimal part. |
fixed point arccos
par | 4.12 fixed point number with the range [-1, 1] |
fixed point arcsin
par | 4.12 fixed point number with the range [-1, 1] |
fixed point cosine
angle | (-32768 to 32767) |
fixed point sine
angle | (-32768 to 32767) |