From 581f50e0bd45a19282d7958975997d376512b195 Mon Sep 17 00:00:00 2001 From: Mel Date: Thu, 7 Dec 2023 01:26:04 +0100 Subject: AABB-AABB dynamic-static collision response with sliding --- src/Math/Vector.hpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/Math/Vector.hpp') 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]; } -- cgit 1.4.1