MathDefs.pkg 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. $#include "MathDefs.h"
  2. static const float M_PI;
  3. static const int M_MIN_INT;
  4. static const int M_MAX_INT;
  5. static const unsigned M_MIN_UNSIGNED;
  6. static const unsigned M_MAX_UNSIGNED;
  7. static const float M_EPSILON;
  8. static const float M_LARGE_EPSILON;
  9. static const float M_MIN_NEARCLIP;
  10. static const float M_MAX_FOV;
  11. static const float M_LARGE_VALUE;
  12. static const float M_INFINITY;
  13. static const float M_DEGTORAD;
  14. static const float M_DEGTORAD_2;
  15. static const float M_RADTODEG;
  16. /// Intersection test result.
  17. enum Intersection
  18. {
  19. OUTSIDE,
  20. INTERSECTS,
  21. INSIDE
  22. };
  23. /// Linear interpolation between two float values.
  24. inline float Lerp(float lhs, float rhs, float t);
  25. /// Return the smaller of two floats.
  26. inline float Min(float lhs, float rhs);
  27. /// Return the larger of two floats.
  28. inline float Max(float lhs, float rhs);
  29. /// Return absolute value of a float.
  30. inline float Abs(float value);
  31. /// Clamp a float to a range.
  32. inline float Clamp(float value, float min, float max);
  33. /// Check whether two floating point values are equal within accuracy.
  34. inline bool Equals(float lhs, float rhs);
  35. /// Return the smaller of two integers.
  36. inline int Min(int lhs, int rhs);
  37. /// Return the larger of two integers.
  38. inline int Max(int lhs, int rhs);
  39. /// Return absolute value of an integer
  40. inline int Abs(int value);
  41. /// Clamp an integer to a range.
  42. inline int Clamp(int value, int min, int max);
  43. /// Check whether an unsigned integer is a power of two.
  44. inline bool IsPowerOfTwo(unsigned value);
  45. /// Round up to next power of two.
  46. inline unsigned NextPowerOfTwo(unsigned value);
  47. /// Update a hash with the given 8-bit value using the SDBM algorithm.
  48. inline unsigned SDBMHash(unsigned hash, unsigned char c);
  49. /// Return a random float between 0.0 (inclusive) and 1.0 (exclusive.)
  50. inline float Random();
  51. /// Return a random float between 0.0 and range, inclusive from both ends.
  52. inline float Random(float range);
  53. /// Return a random integer between 0 and range - 1.
  54. inline int Random @ RandomInt (int range);