Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.2 KiB

  1. // mathx.h
  2. #ifndef __INCLUDE_MATHX
  3. #define __INCLUDE_MATHX
  4. #ifdef __cplusplus
  5. extern "C"
  6. {
  7. #endif
  8. int Arctan2(int y, int x);
  9. int Distance(int a, int b);
  10. int AddLogProb(int a, int b);
  11. #define DISTANCE_POINT(a,b) Distance((a).x - (b).x, (a).y - (b).y)
  12. #define CROSS_PRODUCT(a,b) (((long) (a).x) * ((long) (b).y) - ((long) (a).y) * ((long) (b).x))
  13. // Calculate difference between two angles and bring into range -180 < angle <= 180.
  14. #define ANGLEDIFF(a,b,c) { \
  15. c = b - a; \
  16. if (c > 180) { \
  17. c -= 360; \
  18. } else if (c <= -180) { \
  19. c += 360; \
  20. } \
  21. }
  22. // Calc d = the angle betw (the extension of rgxy[a]:rgxy[b]) and
  23. // (rgxy[b]:rgxy[c]). The sign of d reflects clockwise vs
  24. // counterclockwise turns.
  25. // LEFT FOR A RAINY DAY: make this more efficient
  26. #define CALCANGLE(a,b,c,d) \
  27. ANGLEDIFF(Arctan2(rgxy[b].y - rgxy[a].y, rgxy[b].x - rgxy[a].x), \
  28. Arctan2(rgxy[c].y - rgxy[b].y, rgxy[c].x - rgxy[b].x), \
  29. d);
  30. #define CALCANGLEPT(a,b,c,d) \
  31. ANGLEDIFF(Arctan2(b.y - a.y, b.x - a.x), \
  32. Arctan2(c.y - b.y, c.x - b.x), \
  33. d);
  34. #define INTEGER_LOG_SCALE 256
  35. #define INTEGER_ARCTAN 100
  36. #ifdef __cplusplus
  37. };
  38. #endif
  39. #endif //__INCLUDE_MATHX