fast_math.h 851 B

12345678910111213141516171819202122232425262728293031
  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 SQ(x) ((x)*(x))
  11. void fast_sincos(float angle, float *sin, float *cos);
  12. void fast_norm_angle(float *angle);
  13. void normal_sincosf(float angle, float *sin, float *cos);
  14. /**
  15. * A simple low pass filter.
  16. *
  17. * @param value
  18. * The filtered value.
  19. *
  20. * @param sample
  21. * Next sample.
  22. *
  23. * @param filter_constant
  24. * Filter constant. Range 0.0 to 1.0, where 1.0 gives the unfiltered value.
  25. */
  26. #define LowPass_Filter(value, sample, filter_constant) (value -= (filter_constant) * ((value) - (sample)))
  27. #endif /* _Fast_Math_H__ */