summaryrefslogtreecommitdiff
path: root/source/logic/MazeMath.h
diff options
context:
space:
mode:
Diffstat (limited to 'source/logic/MazeMath.h')
-rw-r--r--source/logic/MazeMath.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/source/logic/MazeMath.h b/source/logic/MazeMath.h
new file mode 100644
index 0000000..d5a2aa9
--- /dev/null
+++ b/source/logic/MazeMath.h
@@ -0,0 +1,59 @@
+#ifndef MAZEMATH_H
+#define MAZEMATH_H
+
+#include <cmath>
+
+/**
+* @brief Class of static methods for common math functions that occur in the 2D maze setting.
+*
+* @author Justin Wernick
+* @author David Schneider
+*/
+class MazeMath
+{
+ public:
+ /**
+ * @brief Rounds a value to the nearest integer.
+ *
+ * Values with a decimal fraction less than 0.5 are floored, while values with
+ * a decimal fraction greater than or eqaul to 0.5 are ceiled.
+ *
+ * @param [in] value The number to be rounded off.
+ *
+ * @return The rounded off version of the given value.
+ */
+ static double round(double value);
+
+ /**
+ * @brief Finds the straight line distance between two points on a 2D plane.
+ *
+ * Implemented using Pythagoras' Theorem.
+ *
+ * @param [in] x1 The x coordinate of the first point.
+ * @param [in] y1 The y coordinate of the first point.
+ * @param [in] x2 The x coordinate of the second point.
+ * @param [in] y2 The y coordinate of the second point.
+ *
+ * @return The distance between the two given points.
+ */
+ static double distance(double x1, double y1, double x2, double y2);
+
+ private:
+ /**
+ * @brief Unimplemented constructor.
+ *
+ * being a grouping of static functions, construction and destruction of MazeMath
+ * objects is unneccesary.
+ */
+ MazeMath();
+ /**
+ * @brief Unimplemented copy constructor.
+ */
+ MazeMath(const MazeMath& ref);
+ /**
+ * @brief Unimplemented assignment operator.
+ */
+ MazeMath& operator=(const MazeMath& rhs);
+};
+
+#endif // MAZEMATH_H