This file is for fast functions for fixed point numbers like trigonometric functions, square root, etc.
sparrowMath | This file is for fast functions for fixed point numbers like trigonometric functions, square root, etc. |
Functions | |
spInitMath | Initializes the fixed point look up tables for sin, cos, etc. |
spSin | Calculates the sinus of a fixed point value |
spCos | Calculates the cosinus of a fixed point value |
spTan | Calculates the tangent of a fixed point value |
spAsin | Calculates the arcus sinus of a fixed point value |
spAcos | Calculates the arcus cosinus of a fixed point value |
spSqrt | Fast square root for fixed point numbers |
spUnsave_Small_Sqrt | This functions returns the square root of a number between 0 and 1 << SP_SQRT_ACCURACY. |
spMin | Returns the smallest of 2 numbers. |
spMax | Returns the biggest of 2 numbers. |
spAtof | Converts a string to a Sint32 fixed point number like atof. |
PREFIX void spInitMath( void )
Initializes the fixed point look up tables for sin, cos, etc. Is called by spInitCore.
PREFIX Sint32 spUnsave_Small_Sqrt( Sint32 n )
This functions returns the square root of a number between 0 and 1 << SP_SQRT_ACCURACY. If you give a number outside this range IT WILL CRASH! So use spSqrt if you are unsure. The light calculation uses this function for fast rendering.
n | as said a fixed point value between 0 and 1 << SP_SQRT_ACCURACY |
Sint32 | the square root of n. Always keep in mind, that the normal fixed point numbers with shift of SP_ACCURACY may not be compatible to this fixed point numbers with shift of SP_SQRT_ACCURACY! |
PREFIX Sint32 spMin( Sint32 a, Sint32 b )
Returns the smallest of 2 numbers. To get the smallest of three and more numbers, use a tree like function call like: spMin(spMin(a,b),c) or spMin(spMin(a,b),spMin(c,d)).
a,b | numbers to compare |
Sint32 | the smaller number. If the numbers are even, it returns the bigger on. |
PREFIX Sint32 spMax( Sint32 a, Sint32 b )
Returns the biggest of 2 numbers. To get the biggest of three and more numbers, use a tree like function call like: spMax(spMax(a,b),c) or spMax(spMax(a,b),spMax(c,d)).
a,b | numbers to compare |
Sint32 | the bigger number. If the numbers are even, it returns the smaller on. |
PREFIX Sint32 spAtof( char * buffer )
Converts a string to a Sint32 fixed point number like atof. Be careful, it is slow, especially on devices without FPU. But perfect for loading stuff.
buffer | string to convert |
Sint32 | the fixed point value stored in buffer. That means, if buffer is “12.3” the fixed point conversion of 12.3 will be saved, which is 806092 and not 12. ;) |
Initializes the fixed point look up tables for sin, cos, etc.
PREFIX void spInitMath( void )
Calculates the sinus of a fixed point value
PREFIX Sint32 spSin( Sint32 value )
Calculates the cosinus of a fixed point value
PREFIX Sint32 spCos( Sint32 value )
Calculates the tangent of a fixed point value
PREFIX Sint32 spTan( Sint32 value )
Calculates the arcus sinus of a fixed point value
PREFIX Sint32 spAsin( Sint32 value )
Calculates the arcus cosinus of a fixed point value
PREFIX Sint32 spAcos( Sint32 value )
Fast square root for fixed point numbers
PREFIX Sint32 spSqrt ( Sint32 n )
This functions returns the square root of a number between 0 and 1 << SP_SQRT_ACCURACY.
PREFIX Sint32 spUnsave_Small_Sqrt( Sint32 n )
Returns the smallest of 2 numbers.
PREFIX Sint32 spMin( Sint32 a, Sint32 b )
Returns the biggest of 2 numbers.
PREFIX Sint32 spMax( Sint32 a, Sint32 b )
Converts a string to a Sint32 fixed point number like atof.
PREFIX Sint32 spAtof( char * buffer )
spInitCore initializes SDL, SDL_TTF and other stuff.
PREFIX void spInitCore( void )