summary refs log tree commit diff
path: root/src/Math/Vector.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Math/Vector.hpp')
-rw-r--r--src/Math/Vector.hpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/Math/Vector.hpp b/src/Math/Vector.hpp
index 4506f0b..acbfa98 100644
--- a/src/Math/Vector.hpp
+++ b/src/Math/Vector.hpp
@@ -100,6 +100,23 @@ struct Vector {
         };
     }
 
+    Vector<3, T> project_onto(const Vector<3, T> other) const {
+        return other * (*this * other) / (other * other);
+    }
+
+    Bool mostly_equal(const Vector other, T epsilon = 0.0001f) const {
+        for (Int i = 0; i < S; i++) {
+            if (!Math::floats_equal(elements[i], other[i], epsilon)) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    Bool is_zero() const {
+        return mostly_equal(zero());
+    }
+
     T operator[](USize index) const {
         return elements[index];
     }