gl3n.aabb
-
Declaration
structAABBT(type, uint dimension_ = 3);Base template for all AABB-types.
Parameters
typeall values get stored as this type
-
Declaration
aliasat= type;Holds the internal type of the AABB.
-
Declaration
aliasvec= Vector!(at, dimension_);Convenience alias to the corresponding vector type.
-
Declaration
vecmin;The minimum of the AABB (e.g. vec(0, 0, 0)).
-
Declaration
vecmax;The maximum of the AABB (e.g. vec(1, 1, 1)).
-
Declaration
this(vecmin, vecmax);Constructs the AABB.
Parameters
vecminminimum of the AABB
vecmaxmaximum of the AABB
-
Declaration
static AABBTfrom_points(vec[]points);Constructs the AABB around N
points(allpointswill be part of the AABB). -
Declaration
voidexpand(AABBTb);Expands the AABB by another AABB.
-
Declaration
voidexpand(vecv);Expands the AABB, so that
vis part of the AABB. -
Declaration
const boolintersects(AABBTbox);Returns
trueif the AABBs intersect. This also returnstrueif one AABB lies inside another. -
Declaration
const @property vecextent();Returns the
extentof the AABB (also sometimes called size). -
Declaration
const @property vechalf_extent();Returns the half extent.
-
Declaration
const @property realarea();Returns the
areaof the AABB.Examples
Returns the
areaof the AABB.alias AABB = AABBT!(at, dimension); AABB a = AABB(sizedVec([0.0, 0.0, 0.0, 0.0]), sizedVec([1.0, 1.0, 1.0, 1.0])); switch (dimension) { case 1: assert(a.area == 0); break; case 2: assert(a.area == 1); break; case 3: assert(a.area == 6); break; default: assert(0); } AABB b = AABB(sizedVec([2.0, 2.0, 2.0, 2.0]), sizedVec([10.0, 10.0, 10.0, 10.0])); switch (dimension) { case 1: assert(b.area == 0); break; case 2: assert(b.area == 64); break; case 3: assert(b.area == 384); break; default: assert(0); } AABB c = AABB(sizedVec([2.0, 4.0, 6.0, 6.0]), sizedVec([10.0, 10.0, 10.0, 10.0])); switch (dimension) { case 1: assert(c.area == 0); break; case 2: assert(almost_equal(c.area, 48.0)); break; case 3: assert(almost_equal(c.area, 208.0)); break; default: assert(0); }
-
Declaration
const @property veccenter();Returns the
centerof the AABB. -
Declaration
const @property vec[]vertices();Returns all
verticesof the AABB, basically one vec per corner.
-