AABBT.area

Returns the area of the AABB.

struct AABBT(type, uint dimension_ = 3)
@safe pure nothrow @property const
static if(dimension <= 3)
real
area
()

Examples

Returns the area of 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);
}

Meta