sandbox
Loading...
Searching...
No Matches
sbx::math::basic_box< Type > Class Template Reference

Plane-based box represented by six clipping planes. More...

#include <box.hpp>

Inheritance diagram for sbx::math::basic_box< Type >:
sbx::scenes::frustum

Public Types

using value_type = Type
 Underlying scalar value type.
 
using plane_type = basic_plane< value_type >
 Plane type used by this box.
 
using volume_type = basic_volume< value_type >
 Volume type tested for intersection.
 
using size_type = std::size_t
 Index type for plane access.
 

Public Member Functions

 basic_box () noexcept=default
 Constructs an empty box.
 
 basic_box (const std::array< plane_type, 6u > &planes) noexcept
 Constructs a box from a plane array. More...
 
 basic_box (std::array< plane_type, 6u > &&planes) noexcept
 Constructs a box by moving in a plane array. More...
 
auto intersects (const volume_type &volume) const -> bool
 Tests whether this box intersects a volume. More...
 
auto planes () const noexcept -> const std::array< plane_type, 6u > &
 Returns the plane array backing this box. More...
 
auto plane (const size_type index) const noexcept -> const plane_type &
 Returns the plane at a given index. More...
 

Detailed Description

template<scalar Type>
class sbx::math::basic_box< Type >

Plane-based box represented by six clipping planes.

The box stores a fixed set of six planes. The intersection test uses a "positive vertex" strategy against an AABB-like volume type.

Template Parameters
TypeScalar value type.

Constructor & Destructor Documentation

◆ basic_box() [1/2]

template<scalar Type>
sbx::math::basic_box< Type >::basic_box ( const std::array< plane_type, 6u > &  planes)
noexcept

Constructs a box from a plane array.

Parameters
planesPlane array describing the box.

◆ basic_box() [2/2]

template<scalar Type>
sbx::math::basic_box< Type >::basic_box ( std::array< plane_type, 6u > &&  planes)
noexcept

Constructs a box by moving in a plane array.

Parameters
planesPlane array describing the box.

Member Function Documentation

◆ intersects()

template<scalar Type>
auto sbx::math::basic_box< Type >::intersects ( const volume_type volume) const -> bool

Tests whether this box intersects a volume.

The test evaluates the volume against each plane using the volume vertex most aligned with the plane normal.

Parameters
volumeVolume to test for intersection.
Returns
True if the volume intersects or is inside the box.

◆ plane()

template<scalar Type>
auto sbx::math::basic_box< Type >::plane ( const size_type  index) const -> const plane_type&
noexcept

Returns the plane at a given index.

Parameters
indexPlane index.
Returns
Reference to the plane at index.

◆ planes()

template<scalar Type>
auto sbx::math::basic_box< Type >::planes
noexcept

Returns the plane array backing this box.

Returns
Reference to the plane array.

The documentation for this class was generated from the following files: