aabb.ixx File
Axis-Aligned Bounding Box (AABB) type and transformations. More...
Included Headers
#include <memory>
#include <cassert>
#include <helios.math.traits.FloatingPointType>
#include <helios.math.concepts>
#include <helios.math.types:mat4>
Namespaces Index
| namespace | helios |
| namespace | math |
|
Mathematical operations and types. More... | |
Classes Index
| struct | aabb<T> |
|
Axis-Aligned Bounding Box for spatial culling and collision detection. More... | |
Description
Axis-Aligned Bounding Box (AABB) type and transformations.
File Listing
The file content with the documentation metadata removed is:
17export namespace helios::math {
31 * @see [DP11, pp. 304-311] Dunn, F., & Parberry, I. (2011). 3D Math Primer for Graphics and Game Development
42 helios::math::vec3<T> min_;
49 helios::math::vec3<T> max_;
61 : min_{std::numeric_limits<T>::max(), std::numeric_limits<T>::max(), std::numeric_limits<T>::max()},
62 max_{std::numeric_limits<T>::lowest(), std::numeric_limits<T>::lowest(), std::numeric_limits<T>::lowest()}
75 constexpr aabb(const T minX, const T minY, const T minZ, const T maxX, const T maxY, const T maxZ) noexcept
86 constexpr aabb(const helios::math::vec3<T> min, const helios::math::vec3<T> max) noexcept
87 : min_(min),
88 max_(max)
96 [[nodiscard]] constexpr const helios::math::vec3<T>& min() const noexcept {
105 [[nodiscard]] constexpr const helios::math::vec3<T>& max() const noexcept {
114 [[nodiscard]] constexpr helios::math::vec3<T> center() const noexcept {
123 [[nodiscard]] constexpr helios::math::vec3<T> size() const noexcept {
137 [[nodiscard]] constexpr bool contains(const helios::math::aabb<T>& box) const noexcept {
154 [[nodiscard]] constexpr bool contains(const helios::math::vec3<T>& point) const noexcept {
166 [[nodiscard]] constexpr bool intersects(const helios::math::aabb<T>& box) const noexcept {
191 [[nodiscard]] constexpr helios::math::aabb<T> translate(const helios::math::vec3<T>& v) const noexcept {
192 return helios::math::aabb<T>{
209 void add(const helios::math::vec3<T>& point) noexcept {
235 [[nodiscard]] aabb<T> applyTransform(const mat4<T>& mat) const noexcept {
241 vec3<T> newMin = {translationX, translationY, translationZ};
242 vec3<T> newMax = newMin;
262 return aabb<T>(newMin, newMax);
282 [[nodiscard]] constexpr helios::math::vec3<T> overlap(
283 const helios::math::aabb<T> a, const helios::math::aabb<T> b) noexcept {
285 const auto overlapMin = helios::math::vec3<T>{
291 const auto overlapMax = helios::math::vec3<T>{
301 * @brief Computes the center of intersection of the overlapping region between two axis-aligned bounding
305 * If the AABBs do not overlap, the returned value represents the midpoint of the gap between them.
311 * @return A 3D vector representing the center point of the overlapping or gapping region between the AABBs.
314 [[nodiscard]] constexpr helios::math::vec3<T> overlapCenter(
315 const helios::math::aabb<T> a, const helios::math::aabb<T> b) noexcept {
317 const auto overlapMin = helios::math::vec3<T>{
323 const auto overlapMax = helios::math::vec3<T>{
345 [[nodiscard]] constexpr helios::math::aabb<T> operator+(
346 const helios::math::aabb<T> aabb, const helios::math::vec3<T> v) noexcept {
363 [[nodiscard]] constexpr helios::math::aabb<T> operator*(
364 const helios::math::aabb<T>& aabb, const helios::math::vec3<T> v) noexcept {
366 return helios::math::aabb<T>{aabb.min() * v, aabb.max() * v};
372 using aabbf = aabb<float>;
382 using aabbui = aabb<unsigned int>;
387 using aabbd = aabb<double>;
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.