GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
grem::Box< N, T > Struct Template Reference

Generic axis-aligned box shape with minimum and maximum extents in N-dimensional space. More...

#include <GREM/core/geometry.hpp>

Public Types

using Component = T
 Scalar coordinate component type.

Public Member Functions

template<typename U>
GREM_ALWAYS_INLINE constexpr operator Box< N, U > () const noexcept
 Convert this box to an equivalent box of another scalar type.
bool operator== (const Box &other) const =default
 Compare this box to another for equality.
constexpr bool contains (const Point< N, T > &point) const noexcept
 Check if a given point is contained within the extents of this box.
constexpr bool intersects (const Ray< N, T > &ray) const noexcept
 Check if this box intersects a given ray.
constexpr RaycastResult< N, T > raycast (const Ray< N, T > &ray) const noexcept
 Find the closest intersection of this box with a given ray.
constexpr Box< N, T > getBoundingBox () const noexcept
 Get the axis-aligned bounding box of the box.
constexpr Box< N, T > toBox () const noexcept
 Convert this shape to an equivalent axis-aligned bounding box.
constexpr Box< N, T > getExpanded (Length< N, T > expansion) const noexcept
 Get a version of the box that is symmetrically expanded by a certain amount.
constexpr Box< N, T > getExpanded (T expansion) const noexcept
 Get a version of the box that is symmetrically expanded by a certain amount.

Public Attributes

Point< N, T > min
 Position with the minimum coordinates of the box extents on each coordinate axis.
Point< N, T > max
 Position with the maximum coordinates of the box extents on each coordinate axis.

Static Public Attributes

static constexpr size_t RANK = N
 Number of dimensions of the vector space.

Detailed Description

template<size_t N, typename T>
struct grem::Box< N, T >

Generic axis-aligned box shape with minimum and maximum extents in N-dimensional space.

Template Parameters
Nnumber of vector dimensions.
Tscalar coordinate component type.

Member Typedef Documentation

◆ Component

template<size_t N, typename T>
using grem::Box< N, T >::Component = T

Scalar coordinate component type.

Member Function Documentation

◆ operator Box< N, U >()

template<size_t N, typename T>
template<typename U>
GREM_ALWAYS_INLINE constexpr grem::Box< N, T >::operator Box< N, U > ( ) const
inlineexplicitconstexprnoexcept

Convert this box to an equivalent box of another scalar type.

Returns
the converted box.

◆ operator==()

template<size_t N, typename T>
bool grem::Box< N, T >::operator== ( const Box< N, T > & other) const
nodiscarddefault

Compare this box to another for equality.

Parameters
otherthe box to compare this box to.
Returns
true if the boxes are equal, false otherwise.

◆ contains()

template<size_t N, typename T>
bool grem::Box< N, T >::contains ( const Point< N, T > & point) const
inlinenodiscardconstexprnoexcept

Check if a given point is contained within the extents of this box.

Parameters
pointpoint to check.
Returns
true if the box contains the given point, false otherwise.

◆ intersects()

template<size_t N, typename T>
bool grem::Box< N, T >::intersects ( const Ray< N, T > & ray) const
inlinenodiscardconstexprnoexcept

Check if this box intersects a given ray.

Parameters
rayray to check.
Returns
true if an intersection was found, false otherwise.

◆ raycast()

template<size_t N, typename T>
RaycastResult< N, T > grem::Box< N, T >::raycast ( const Ray< N, T > & ray) const
inlinenodiscardconstexprnoexcept

Find the closest intersection of this box with a given ray.

Parameters
rayray to check.
Returns
the result of the raycast.

◆ getBoundingBox()

template<size_t N, typename T>
Box< N, T > grem::Box< N, T >::getBoundingBox ( ) const
inlinenodiscardconstexprnoexcept

Get the axis-aligned bounding box of the box.

Returns
an axis-aligned box that contains the entire box.

◆ toBox()

template<size_t N, typename T>
Box< N, T > grem::Box< N, T >::toBox ( ) const
inlinenodiscardconstexprnoexcept

Convert this shape to an equivalent axis-aligned bounding box.

Returns
an axis-aligned box that is equivalent to this shape.

◆ getExpanded() [1/2]

template<size_t N, typename T>
Box< N, T > grem::Box< N, T >::getExpanded ( Length< N, T > expansion) const
inlinenodiscardconstexprnoexcept

Get a version of the box that is symmetrically expanded by a certain amount.

Parameters
expansiondistance to expand the box by along each axis. Each component must be non-negative.
Returns
the expanded box.

◆ getExpanded() [2/2]

template<size_t N, typename T>
Box< N, T > grem::Box< N, T >::getExpanded ( T expansion) const
inlinenodiscardconstexprnoexcept

Get a version of the box that is symmetrically expanded by a certain amount.

Parameters
expansiondistance to expand the box by along each axis. Must be non-negative.
Returns
the expanded box.

Member Data Documentation

◆ RANK

template<size_t N, typename T>
size_t grem::Box< N, T >::RANK = N
staticconstexpr

Number of dimensions of the vector space.

◆ min

template<size_t N, typename T>
Point<N, T> grem::Box< N, T >::min

Position with the minimum coordinates of the box extents on each coordinate axis.

◆ max

template<size_t N, typename T>
Point<N, T> grem::Box< N, T >::max

Position with the maximum coordinates of the box extents on each coordinate axis.


The documentation for this struct was generated from the following file: