gfm

This module implements a generic axis-aligned bounding  box (AABB).


struct  Box(T, int N);

N-dimensional half-open interval [a, b[.


pure nothrow @nogc this(bound_t min_, bound_t max_);

Construct a box which extends between 2 points.

Boundaries:
min is inside the box, max is just outside.

const pure nothrow @nogc bound_t  size();

Returns
Dimensions of the box.

const pure nothrow @nogc bound_t  center();

Returns
Center of the box.

const pure nothrow @nogc @property T  width();

Returns
Width of the box, always applicable.

const pure nothrow @nogc @property T  height();

Returns
Height of the box, if applicable.

const pure nothrow @nogc @property T  depth();

Returns
Depth of the box, if applicable.

const pure nothrow @nogc T  volume();

Returns
Signed  volume of the box.

const pure nothrow @nogc bool  empty();

Returns
true if  empty.

const pure nothrow @nogc bool  contains(bound_t point);

Returns
true if it  contains point.

const pure nothrow @nogc bool  contains(Box other);

Returns
true if it  contains box other.

const pure nothrow @nogc real  squaredDistance(bound_t point);

Euclidean squared distance from a point.

See Also
Numerical Recipes Third Edition (2007)

const pure nothrow @nogc real  distance(bound_t point);

Euclidean  distance from a point.

See Also
squaredDistance.

const pure nothrow @nogc real  squaredDistance(Box o);

Euclidean squared distance from another box.

See Also
Numerical Recipes Third Edition (2007)

const pure nothrow @nogc real  distance(Box o);

Euclidean  distance from another box.

See Also
squaredDistance.

const pure nothrow @nogc Box  intersection(Box o);

Assumes sorted boxes.

This function deals with empty boxes correctly.

Returns
Intersection of two boxes.

const pure nothrow @nogc bool  intersects(Box other);

Assumes sorted boxes.

This function deals with empty boxes correctly.

Returns
Intersection of two boxes.

const pure nothrow @nogc Box  grow(bound_t space);

Extends the area of this Box.


const pure nothrow @nogc Box  shrink(bound_t space);

Shrink the area of this Box. The box might became unsorted.


const pure nothrow @nogc Box  grow(T space);

Extends the area of this Box.


const pure nothrow @nogc Box  translate(bound_t offset);

Translate this Box.


const pure nothrow @nogc Box  shrink(T space);

Shrinks the area of this Box.

Returns
Shrinked box.

const pure nothrow @nogc Box  expand(bound_t point);

Expands the box to include point.

Returns
Expanded box.

const pure nothrow @nogc Box  expand(Box other);

Expands the box to include another box.

This function deals with empty boxes correctly.

Returns
Expanded box.

const pure nothrow @nogc bool  isSorted();

Returns
true if each dimension of the box is >= 0.

nothrow @nogc ref Box  opAssign(U)(U x) if (isBox!U);

Assign with another box.


const pure nothrow @nogc bool  opEquals(U)(U other) if (is(U : Box));

Returns
true if comparing equal boxes.

static pure nothrow @nogc Box  rectangle(T x, T y, T width, T height);

Helper function to create  rectangle with a given point, width and height.


template  box2(T)

Instanciate to use a 2D box.


template  box3(T)

Instanciate to use a 3D box.


alias  box2i = Box!(int, 2).Box;

2D box with integer coordinates.


alias  box3i = Box!(int, 3).Box;

3D box with integer coordinates.


alias  box2f = Box!(float, 2).Box;

2D box with float coordinates.


alias  box3f = Box!(float, 3).Box;

3D box with float coordinates.


alias  box2d = Box!(double, 2).Box;

2D box with double coordinates.


alias  box3d = Box!(double, 3).Box;

3D box with double coordinates.


enum auto  isBox(T);

True if

T
is a kind of Box


template  DimensionType(T : Box!U, U...)

Get the numeric type used to measure a box's dimensions.

Examples
static assert(is(DimensionType!box2f == float));
static assert(is(DimensionType!box3d == double));