55 #ifndef _MGUI_MGHAVE_FIXED_MATH_H 56 #define _MGUI_MGHAVE_FIXED_MATH_H 68 #ifdef _MGHAVE_FIXED_MATH 154 extern MG_EXPORT
fixed _cos_tbl[];
155 extern MG_EXPORT
fixed _tan_tbl[];
156 extern MG_EXPORT
fixed _acos_tbl[];
185 return (
long)(x * 65536.0 + (x < 0 ? -0.5 : 0.5));
199 return (
double)x / 65536.0;
219 fixed result = x + y;
222 if ((x < 0) && (y < 0)) {
230 if ((x > 0) && (y > 0)) {
256 fixed result = x - y;
259 if ((x < 0) && (y > 0)) {
267 if ((x > 0) && (y < 0)) {
318 if (x > 0x7FFF0000) {
327 return ~((~x) >> 16);
353 return (x >> 16) + ((x & 0x8000) >> 15);
367 return _cos_tbl[((x + 0x4000) >> 15) & 0x1FF];
381 return _cos_tbl[((x - 0x400000 + 0x4000) >> 15) & 0x1FF];
395 return _tan_tbl[((x + 0x4000) >> 15) & 0xFF];
413 if ((x < -65536) || (x > 65536)) {
418 return _acos_tbl[(x+65536+127)>>8];
436 if ((x < -65536) || (x > 65536)) {
441 return 0x00400000 - _acos_tbl[(x+65536+127)>>8];
static fixed fixsin(fixed x)
Returns the sine of a fixed point.
MG_EXPORT fixed fixmul(fixed x, fixed y)
Returns the product of two fixed point values.
static fixed fixcos(fixed x)
Returns the cosine of a fixed point.
static fixed fixasin(fixed x)
Calculates and returns the arc sine of a fixed point.
MG_EXPORT fixed fixatan(fixed x)
Calculates the arc tangent of a fixed point value.
static fixed fixadd(fixed x, fixed y)
Returns the sum of two fixed point values.
static int fixtoi(fixed x)
Converts an fixed point value to an integer.
static double fixtof(fixed x)
Converts a fixed point value to a float point value.
MG_EXPORT fixed fixdiv(fixed x, fixed y)
Returns the quotient of two fixed point values.
static fixed ftofix(double x)
Converts a float point value to a fixed point value.
static fixed fixacos(fixed x)
Calculates and returns the arc cosine of a fixed point.
static fixed itofix(int x)
Converts an integer to a fixed point value.
long fixed
Data type of fixed point.
static fixed fixsub(fixed x, fixed y)
Subtract a fixed point value from another.
static int fixceil(fixed x)
Rounds a fixed point value to the nearest integer.
MG_EXPORT fixed fixhypot(fixed x, fixed y)
Returns the Euclidean distance from the origin.
static fixed fixtan(fixed x)
Returns the tangent of a fixed point.
MG_EXPORT fixed fixatan2(fixed y, fixed x)
Calculates the arc tangent of two fixed point variables.
MG_EXPORT fixed fixsqrt(fixed x)
Returns the non-negative square root of a fixed point value.