diff --git a/include/omath/3d_primitives/aabb.hpp b/include/omath/3d_primitives/aabb.hpp index e6fbc47..fddccfd 100644 --- a/include/omath/3d_primitives/aabb.hpp +++ b/include/omath/3d_primitives/aabb.hpp @@ -12,5 +12,17 @@ namespace omath::primitives { Vector3 min; Vector3 max; + + [[nodiscard]] + constexpr Vector3 center() const noexcept + { + return (min + max) / static_cast(2); + } + + [[nodiscard]] + constexpr Vector3 extents() const noexcept + { + return (max - min) / static_cast(2); + } }; } // namespace omath::primitives diff --git a/include/omath/collision/line_tracer.hpp b/include/omath/collision/line_tracer.hpp index 65b253e..324f80b 100644 --- a/include/omath/collision/line_tracer.hpp +++ b/include/omath/collision/line_tracer.hpp @@ -3,7 +3,7 @@ // #pragma once -#include "omath/linear_algebra/aabb.hpp" +#include "omath/3d_primitives/aabb.hpp" #include "omath/linear_algebra/triangle.hpp" #include "omath/linear_algebra/vector3.hpp" @@ -35,7 +35,7 @@ namespace omath::collision class LineTracer final { using TriangleType = Triangle; - using AABBType = AABB; + using AABBType = primitives::Aabb; public: LineTracer() = delete; diff --git a/include/omath/linear_algebra/aabb.hpp b/include/omath/linear_algebra/aabb.hpp deleted file mode 100644 index 4faac54..0000000 --- a/include/omath/linear_algebra/aabb.hpp +++ /dev/null @@ -1,33 +0,0 @@ -// -// Created by Vlad on 3/25/2025. -// -#pragma once - -#include "omath/linear_algebra/vector3.hpp" - -namespace omath -{ - template> - class AABB final - { - public: - using VectorType = Vector; - - VectorType min; - VectorType max; - - constexpr AABB(const VectorType& min, const VectorType& max) noexcept : min(min), max(max) {} - - [[nodiscard]] - constexpr VectorType center() const noexcept - { - return (min + max) / static_cast(2); - } - - [[nodiscard]] - constexpr VectorType extents() const noexcept - { - return (max - min) / static_cast(2); - } - }; -} // namespace omath diff --git a/tests/general/unit_test_line_tracer_aabb.cpp b/tests/general/unit_test_line_tracer_aabb.cpp index 00b7788..7607220 100644 --- a/tests/general/unit_test_line_tracer_aabb.cpp +++ b/tests/general/unit_test_line_tracer_aabb.cpp @@ -2,14 +2,13 @@ // Created by Vlad on 3/25/2025. // #include "omath/collision/line_tracer.hpp" -#include "omath/linear_algebra/aabb.hpp" -#include "omath/linear_algebra/vector3.hpp" +#include "omath/3d_primitives/aabb.hpp" #include using Vec3 = omath::Vector3; using Ray = omath::collision::Ray<>; using LineTracer = omath::collision::LineTracer<>; -using AABB = omath::AABB; +using AABB = omath::primitives::Aabb; static Ray make_ray(Vec3 start, Vec3 end, bool infinite = false) {