|
mal-math
C++20 mathematics library.
|
A templated bounding box structure in 3D. More...
#include "box.hpp"
Public Types | |
| using | vector3 = vec<3, T> |
| Type alias for 3D vectors. | |
Public Member Functions | |
| constexpr vector3 | size () const |
| Returns the dimensions of the box. | |
| constexpr vector3 | center () const |
| Returns the center point of the box. | |
| constexpr T | radius () const |
| Returns the radius of a sphere that tightly encloses the box. | |
| void | reset () |
| Resets the box to its default state. | |
| template<typename U > | |
| void | expand (const TBox< U > &other) |
| Expands the box to include another box. | |
| template<AnyVec U> requires (U::size == 3) | |
| void | expand (const U &point) |
| Expands the box to include a point. | |
| bool | contains (const vector3 &P) const |
| Checks if the box contains a given point. | |
| bool | Intersect (Ray const &ray, T &nearest_t) const |
| Checks if a ray intersects with the box and updates the nearest intersection distance. | |
| bool | Intersect (Ray const &ray, Intersection &nearest) const |
| Checks if a ray intersects with the box and updates the nearest intersection point. | |
Static Public Member Functions | |
| static constexpr TBox | empty () |
| Returns an empty box. | |
| static constexpr TBox | unit () |
| Returns a unit box. | |
Public Attributes | |
| vector3 | min |
| The minimum point of the box in 3D space. | |
| vector3 | max |
| The maximum point of the box in 3D space. | |
Static Public Attributes | |
| static constexpr T | Inf = std::numeric_limits<T>::infinity() |
| Infinity value for the primitive type used to define the box coordinates. | |
A templated bounding box structure in 3D.
TBox is a structure that encapsulates a box defined by a minimum and maximum point in 3D space.
| T | The primitive type used to define the box coordinates (e.g., float, double). |
| using mal_math::TBox< T >::vector3 = vec<3, T> |
|
inlineconstexpr |
|
inline |
|
inlinestaticconstexpr |
|
inline |
|
inline |
|
inline |
Checks if a ray intersects with the box and updates the nearest intersection point.
| ray | The ray to be checked for intersection. | |
| [out] | nearest | The nearest intersection point is stored here if an intersection occurs. |
Definition at line 155 of file box.hpp.
|
inline |
Checks if a ray intersects with the box and updates the nearest intersection distance.
| ray | The ray to be checked for intersection. | |
| [out] | nearest_t | The nearest intersection distance is stored here if an intersection occurs. |
Definition at line 105 of file box.hpp.
|
inlineconstexpr |
|
inline |
|
inlineconstexpr |
|
inlinestaticconstexpr |
|
staticconstexpr |
| vector3 mal_math::TBox< T >::max |
| vector3 mal_math::TBox< T >::min |