Struct AABB

Axis-aligned bounding box

struct AABB ;

Example

import dlib.math.utils;

AABB aabb1 = AABB(Vector3f(0, 0, 0), Vector3f(1, 1, 1));
AABB aabb2 = AABB(Vector3f(0.5, 0.5, 0.5), Vector3f(1, 1, 1));
AABB aabb3 = AABB(Vector3f(3, 0, 0), Vector3f(1, 1, 1));

assert(aabb1.containsPoint(Vector3f(0, 0, 0)));
assert(!aabb3.containsPoint(Vector3f(0, 0, 0)));

assert(aabb1.intersectsAABB(aabb2));
assert(!aabb1.intersectsAABB(aabb3));

Vector3f segStart = Vector3f(0, 0, 3);
Vector3f segEnd = Vector3f(0, 0, -3);
float segLength = distance(segStart, segEnd);
float t;
assert(aabb1.intersectsSegment(Vector3f(0, 0, 3), Vector3f(0, 0, -3), t));
assert(isConsiderZero(t * segLength - 2.0f));

assert(!aabb1.intersectsSegment(Vector3f(5, 0, 3), Vector3f(5, 0, -3), t));