SA_Maths
Sapphire Suite's C++ Maths Library
Loading...
Searching...
No Matches
AABB3D.hpp
Go to the documentation of this file.
1// Copyright (c) 2023 Sapphire's Suite. All Rights Reserved.
2
3#pragma once
4
5#ifndef SAPPHIRE_MATHS_AABB3D_GUARD
6#define SAPPHIRE_MATHS_AABB3D_GUARD
7
9
19namespace SA
20{
21 template <typename T>
22 struct AABB2D;
23
29 template <typename T>
30 struct AABB3D
31 {
34
37
38
39//{ Constructors
40
42 AABB3D() = default;
43
50 AABB3D(const Vec3<T>& _min, const Vec3<T>& _max);
51
58 AABB3D(const AABB3D& _first, const AABB3D& _second);
59
65 AABB3D(const AABB2D<T>& _aabb2D) noexcept;
66
67//}
68
69
70//{ Equals
71
77 bool IsValid() const noexcept;
78
79
88 constexpr bool Equals(const AABB3D& _other, T _epsilon = std::numeric_limits<T>::epsilon()) const noexcept;
89
90
98 constexpr bool operator==(const AABB3D& _rhs) const noexcept;
99
107 constexpr bool operator!=(const AABB3D& _rhs) const noexcept;
108
109//}
110
111
112//{ Collisions
113
121 bool IsCollidingX(const AABB3D& _other) const;
122
130 bool IsCollidingY(const AABB3D& _other) const;
131
139 bool IsCollidingZ(const AABB3D& _other) const;
140
148 bool IsColliding(const AABB3D& _other) const;
149
150//}
151
152
153//{ Geometry
154
160 float Width() const;
161
167 float Height() const;
168
174 float Depth() const;
175
181 Vec3<T> Center() const;
182
188 float Area() const;
189
190//}
191
192
201 static AABB3D Merge(const AABB3D& _first, const AABB3D& _second);
202
203 };
204
205
206#if SA_LOGGER_IMPL
207
219 template <typename T>
220 std::string ToString(const AABB3D<T>& _aabb);
221
222#endif
223
224
225//{ Aliases
226
229
232
233//}
234
235}
236
237
240#include <SA/Maths/Geometry/AABB3D.inl>
241
242#endif // GUARD
Vector 3 type implementation.
AABB 2D Sapphire's class.
Definition AABB2D.hpp:32
AABB 3D Sapphire's class.
Definition AABB3D.hpp:31
bool IsColliding(const AABB3D &_other) const
Perform collision test on every axis.
float Depth() const
Compute depth (Z axis) from min and max.
constexpr bool Equals(const AABB3D &_other, T _epsilon=std::numeric_limits< T >::epsilon()) const noexcept
Compare 2 AABB3D.
Vec3< T > max
Max box component.
Definition AABB3D.hpp:36
bool IsCollidingX(const AABB3D &_other) const
Perform collision test on X axis only.
Vec3< T > Center() const
Compute center from min and max.
AABB3D(const AABB3D &_first, const AABB3D &_second)
Merge 2 AABB box.
Vec3< T > min
Min box component.
Definition AABB3D.hpp:33
bool IsCollidingY(const AABB3D &_other) const
Perform collision test on Y axis only.
float Area() const
Compute area from min and max.
bool IsCollidingZ(const AABB3D &_other) const
Perform collision test on Z axis only.
AABB3D()=default
Default constructor.
AABB3D(const Vec3< T > &_min, const Vec3< T > &_max)
Value constructor from min and max.
float Width() const
Compute width (X axis) from min and max.
static AABB3D Merge(const AABB3D &_first, const AABB3D &_second)
Merge 2 AABB3D box to create a big AABB3D which wrap both boxes.
AABB3D(const AABB2D< T > &_aabb2D) noexcept
Constructor from AABB2D.
float Height() const
Compute height (Y axis) from min and max.
bool IsValid() const noexcept
Wether this AABB has valid values (ie min < max);.
Vector 3 Sapphire-Maths class.
Definition Vector3.hpp:43