fast_math.h 781 B

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