fast_math.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #ifndef _Fast_Math_H__
  2. #define _Fast_Math_H__
  3. // Constants
  4. #define ONE_BY_SQRT3 (0.57735026919f) // 1/sqrt(3)
  5. #define TWO_BY_SQRT3 (2.0f * 0.57735026919f)
  6. #define SQRT3_BY_2 (0.86602540378f)
  7. #define SQRT3 (1.73205080757f)
  8. #define SQRT2_BY_SQRT3 (0.8164966f)
  9. #define M_PI (3.14159265f)
  10. #define ONE_BY_SQRT3_Q14 (9459L) //0.57735026919 * 16384.0F
  11. #define SQRT3_BY_2_Q14 (14189L)//0.86602540378 * 16384.0F
  12. #define TWO_BY_SQRT3_Q14 (18918L)
  13. #ifndef SQ
  14. #define SQ(x) ((x)*(x))
  15. #endif
  16. void fast_sincos(float angle, float *sin, float *cos);
  17. void fast_norm_angle(float *angle);
  18. void normal_sincosf(float angle, float *sin, float *cos);
  19. /**
  20. * A simple low pass filter.
  21. *
  22. * @param value
  23. * The filtered value.
  24. *
  25. * @param sample
  26. * Next sample.
  27. *
  28. * @param filter_constant
  29. * Filter constant. Range 0.0 to 1.0, where 1.0 gives the unfiltered value.
  30. */
  31. #define LowPass_Filter(value, sample, filter_constant) (value = value * (1.0f - filter_constant) + sample * filter_constant)
  32. #endif /* _Fast_Math_H__ */