Browse Source

Add some nice math helping functions

Godzil 4 years ago
parent
commit
7b07106816
2 changed files with 32 additions and 0 deletions
  1. 15 0
      source/include/math_helper.h
  2. 17 0
      source/math_helper.cpp

+ 15 - 0
source/include/math_helper.h

@@ -0,0 +1,15 @@
+/*
+ *  DoRayMe - a quick and dirty Raytracer
+ *  Math helping function header
+ *
+ *  Created by Manoël Trapier
+ *  Copyright (c) 2020 986-Studio.
+ *
+ */
+
+#ifndef DORAYME_MATH_HELPER_H
+#define DORAYME_MATH_HELPER_H
+
+bool double_equal(double a, double b);
+
+#endif //DORAYME_MATH_HELPER_H

+ 17 - 0
source/math_helper.cpp

@@ -0,0 +1,17 @@
+/*
+ *  DoRayMe - a quick and dirty Raytracer
+ *  Math helping functions
+ *
+ *  Created by Manoël Trapier
+ *  Copyright (c) 2020 986-Studio.
+ *
+ */
+
+#include <math.h>
+#include <float.h>
+#include <math_helper.h>
+
+bool double_equal(double a, double b)
+{
+    return fabs(a - b) < DBL_EPSILON;
+}