summary refs log tree commit diff
path: root/src/Math/AABB.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Math/AABB.hpp')
-rw-r--r--src/Math/AABB.hpp25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/Math/AABB.hpp b/src/Math/AABB.hpp
index 2c02abf..11d26a8 100644
--- a/src/Math/AABB.hpp
+++ b/src/Math/AABB.hpp
@@ -1,10 +1,27 @@
 #pragma once
-#include "Vector.hpp"
 
-namespace Math {
+#include <array>
+#include "Vector.hpp"
 
 struct AABB {
+    AABB() = default;
+    AABB(Vector<3> min, Vector<3> max) : min(min), max(max) {}
+    explicit AABB(Vector<3> max) : max(max) {}
+
+    std::array<Vector<3>, 8> corners() const {
+        return {{
+            {min.x(), min.y(), min.z()},
+            {min.x(), min.y(), max.z()},
+            {min.x(), max.y(), min.z()},
+            {min.x(), max.y(), max.z()},
+            {max.x(), min.y(), min.z()},
+            {max.x(), min.y(), max.z()},
+            {max.x(), max.y(), min.z()},
+            {max.x(), max.y(), max.z()},
+        }};
+    }
+
+    AABB offset(Vector<3> by) const { return {min + by, max + by}; }
+
     Vector<3> min, max;
 };
-
-}