math_helper.cpp 476 B

1234567891011121314151617181920212223242526272829
  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. bool double_equal(double a, double b)
  18. {
  19. return fabs(a - b) < current_precision;
  20. }
  21. double deg_to_rad(double deg)
  22. {
  23. return deg * M_PI / 180.;
  24. }