math_defs.h 715 B

1234567891011121314151617181920212223242526272829303132333435
  1. #ifndef AL_MATH_DEFS_H
  2. #define AL_MATH_DEFS_H
  3. #include <math.h>
  4. #ifdef HAVE_FLOAT_H
  5. #include <float.h>
  6. #endif
  7. #define F_PI (3.14159265358979323846f)
  8. #define F_PI_2 (1.57079632679489661923f)
  9. #define F_TAU (6.28318530717958647692f)
  10. #ifndef FLT_EPSILON
  11. #define FLT_EPSILON (1.19209290e-07f)
  12. #endif
  13. #ifndef HUGE_VALF
  14. static const union msvc_inf_hack {
  15. unsigned char b[4];
  16. float f;
  17. } msvc_inf_union = {{ 0x00, 0x00, 0x80, 0x7F }};
  18. #define HUGE_VALF (msvc_inf_union.f)
  19. #endif
  20. #ifndef HAVE_LOG2F
  21. static inline float log2f(float f)
  22. {
  23. return logf(f) / logf(2.0f);
  24. }
  25. #endif
  26. #define DEG2RAD(x) ((float)(x) * (F_PI/180.0f))
  27. #define RAD2DEG(x) ((float)(x) * (180.0f/F_PI))
  28. #endif /* AL_MATH_DEFS_H */