math_helper.cpp 531 B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * DoRayMe - a quick and dirty Raytracer
  3. * Math helping functions
  4. *
  5. * Created by Manoël Trapier
  6. * Copyright (c) 2020 986-Studio.
  7. *
  8. */
  9. #include <math.h>
  10. #include <float.h>
  11. #include <math_helper.h>
  12. static double current_precision = FLT_EPSILON;
  13. void set_equal_precision(double v)
  14. {
  15. current_precision = v;
  16. }
  17. double getEpsilon()
  18. {
  19. return current_precision;
  20. }
  21. bool double_equal(double a, double b)
  22. {
  23. return fabs(a - b) < current_precision;
  24. }
  25. double deg_to_rad(double deg)
  26. {
  27. return deg * M_PI / 180.;
  28. }