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

3D axis-aligned cube shape with a position and width. 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 Cube< U > () const noexcept
 Convert this cube to an equivalent cube of another scalar type.
constexpr operator Box< 3, T > () const noexcept
 Convert this cube to an equivalent 2D axis-aligned box.
bool operator== (const Cube &other) const =default
 Compare this cube to another for equality.
constexpr bool contains (const Point< 3, T > &point) const noexcept
 Check if a given point is contained within the extents of this cube.
constexpr bool intersects (const Ray< 3, T > &ray) const noexcept
 Check if this cube intersects a given ray.
constexpr RaycastResult< 3, T > raycast (const Ray< 3, T > &ray) const noexcept
 Find the closest intersection of this cube with a given ray.
constexpr Box< 3, T > getBoundingBox () const noexcept
 Get the axis-aligned bounding box of the cube.
constexpr Box< 3, T > toBox () const noexcept
 Convert this shape to an equivalent axis-aligned bounding box.

Public Attributes

Point< 3, T > position
 Position of the far bottom left corner of the cube.
T width
 Width, height and depth of the cube.

Static Public Attributes

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

Detailed Description

template<typename T>
struct grem::Cube< T >

3D axis-aligned cube shape with a position and width.

Template Parameters
Tscalar coordinate component type.

Member Typedef Documentation

◆ Component

template<typename T>
using grem::Cube< T >::Component = T

Scalar coordinate component type.

Member Function Documentation

◆ operator Cube< U >()

template<typename T>
template<typename U>
GREM_ALWAYS_INLINE constexpr grem::Cube< T >::operator Cube< U > ( ) const
inlineexplicitconstexprnoexcept

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

Returns
the converted cube.

◆ operator Box< 3, T >()

template<typename T>
grem::Cube< T >::operator Box< 3, T > ( ) const
inlineconstexprnoexcept

Convert this cube to an equivalent 2D axis-aligned box.

Returns
the cube as an axis-aligned box.

◆ operator==()

template<typename T>
bool grem::Cube< T >::operator== ( const Cube< T > & other) const
nodiscarddefault

Compare this cube to another for equality.

Parameters
otherthe cube to compare this cube to.
Returns
true if the cubes are equal, false otherwise.

◆ contains()

template<typename T>
bool grem::Cube< T >::contains ( const Point< 3, T > & point) const
inlinenodiscardconstexprnoexcept

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

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

◆ intersects()

template<typename T>
bool grem::Cube< T >::intersects ( const Ray< 3, T > & ray) const
inlinenodiscardconstexprnoexcept

Check if this cube intersects a given ray.

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

◆ raycast()

template<typename T>
RaycastResult< 3, T > grem::Cube< T >::raycast ( const Ray< 3, T > & ray) const
inlinenodiscardconstexprnoexcept

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

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

◆ getBoundingBox()

template<typename T>
Box< 3, T > grem::Cube< T >::getBoundingBox ( ) const
inlinenodiscardconstexprnoexcept

Get the axis-aligned bounding box of the cube.

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

◆ toBox()

template<typename T>
Box< 3, T > grem::Cube< 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.

Member Data Documentation

◆ RANK

template<typename T>
size_t grem::Cube< T >::RANK = 3
staticconstexpr

Number of dimensions of the vector space.

◆ position

template<typename T>
Point<3, T> grem::Cube< T >::position

Position of the far bottom left corner of the cube.

◆ width

template<typename T>
T grem::Cube< T >::width

Width, height and depth of the cube.


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