math_helper.h 580 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * DoRayMe - a quick and dirty Raytracer
  3. * Math helping function header
  4. *
  5. * Created by Manoël Trapier
  6. * Copyright (c) 2020 986-Studio.
  7. *
  8. */
  9. #ifndef DORAYME_MATH_HELPER_H
  10. #define DORAYME_MATH_HELPER_H
  11. #include <math.h>
  12. void set_equal_precision(double v);
  13. double getEpsilon();
  14. bool double_equal(double a, double b);
  15. double deg_to_rad(double deg);
  16. double min3(double a, double b, double c);
  17. double max3(double a, double b, double c);
  18. double frand();
  19. static double modulo(double a, double b)
  20. {
  21. return a - floor(a/b) * b;
  22. }
  23. #endif /* DORAYME_MATH_HELPER_H */