fixed point trig functions. Angle can be in the range of -32768 to 32767. There are 32768 degrees in the unit circle used by nds. To convert between standard degrees (360 per circle): More...
#include <nds/ndstypes.h>Defines | |
| #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. | |
| #define | fixedToInt(n, bits) ((int)((n)>>(bits))) |
| convert a fixed point number to an integer. | |
| #define | floatToFixed(n, bits) ((int)((n) * (float)(1<<(bits)))) |
| converts a floating point number to a fixed point number. | |
| #define | floorFixed(n, bits) ((int)((n) & ~(((1 << (bits)) - 1)))) |
| removes the decimal part of a fixed point number. | |
| #define | intToFixed(n, bits) ((int)((n)<<(bits))) |
| converts an integer to a fixed point number. | |
Functions | |
| s16 | acosLerp (s16 par) |
| fixed point arccos | |
| s16 | asinLerp (s16 par) |
| fixed point arcsin | |
| s16 | cosLerp (s16 angle) |
| fixed point cosine | |
| s16 | sinLerp (s16 angle) |
| fixed point sine | |
| s32 | tanLerp (s16 angle) |
| fixed point tangent | |
fixed point trig functions. Angle can be in the range of -32768 to 32767. There are 32768 degrees in the unit circle used by nds. To convert between standard degrees (360 per circle):
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 | parameter |
fixed point arcsin
| par | parameter |
fixed point cosine
| angle | (-32768 to 32767) |
fixed point sine
| angle | (-32768 to 32767) |
1.6.3