diff options
| author | Mel <einebeere@gmail.com> | 2023-12-07 01:26:04 +0100 |
|---|---|---|
| committer | Mel <einebeere@gmail.com> | 2023-12-07 01:26:04 +0100 |
| commit | 581f50e0bd45a19282d7958975997d376512b195 (patch) | |
| tree | db42e31524efc49caab06efeb3d1a1331ec4f2b5 /src/Math/Vector.hpp | |
| parent | acc6e0e53d981428c15baf5b7efe568d98044290 (diff) | |
| download | meowcraft-581f50e0bd45a19282d7958975997d376512b195.tar.zst meowcraft-581f50e0bd45a19282d7958975997d376512b195.zip | |
AABB-AABB dynamic-static collision response with sliding
Diffstat (limited to 'src/Math/Vector.hpp')
| -rw-r--r-- | src/Math/Vector.hpp | 17 |
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]; } |
