boundingBox method

  1. @override
BoundingBox3D boundingBox()
override

Calculates the axis-aligned bounding box (AABB) of the 3D shape.

Returns a BoundingBox3D that fully contains the shape. The bounding box is aligned with the coordinate axes.

This method must be implemented by subclasses.

Implementation

@override
BoundingBox3D boundingBox() {
  double halfSide = sideLength / 2;
  return BoundingBox3D(
    Point(center.x - halfSide, center.y - halfSide, center.z! - halfSide),
    Point(center.x + halfSide, center.y + halfSide, center.z! + halfSide),
  );
}