#include <darts/box.h>
template<int N, typename T>
Box struct

An N-D axis-aligned bounding box consisting of two N-D points min and max.

Constructors, destructors, conversion operators

Box()
Create an empty box by default.
Box(const Vec<N, T>& p) explicit
Create a box containing a single point in space.
Box(const Vec<N, T>& mn, const Vec<N, T>& mx)
Create a box by specifying the min and max corners.

Public functions

auto contains(const Vec<N, T>& point, bool proper = false) const -> bool
Check whether the box contains this point.
auto volume() const -> T
Calculate the N-dimensional volume of the bounding box.
auto area() const -> T
Calculate the N-1 dimensional volume of the boundary.
auto intersect(const Ray<N, T>& ray, T* hitt0 = nullptr, T* hitt1 = nullptr) const -> bool
Check whether a Ray intersects this Box.

Public variables

Vec<N, T> min
The lower-bound of the interval.
Vec<N, T> max
The upper-bound of the interval.

Function documentation

template<int N, typename T>
bool Box<N, T>::intersect(const Ray<N, T>& ray, T* hitt0 = nullptr, T* hitt1 = nullptr) const

Check whether a Ray intersects this Box.

Parameters
ray The ray along which to check for intersection
hitt0 If not null, stores the lower bound of the intersection interval
hitt1 If not null, stores the upper bound of the intersection interval
Returns true if there is an intersection