brepjs API Reference
    Preparing search index...

    Function principalBoundingBox

    • Measure a solid's bounding box on its principal axes of inertia.

      getBounds answers in world axes, so a board turned 30 degrees reports an inflated box with no frame. This box follows the part's own frame instead: it is the axis-aligned box in the frame of the principal axes of the volume inertia tensor about the center of mass.

      This is NOT a minimum-volume oriented bounding box. When principal moments coincide, the principal axes in that plane are not unique and the box can be larger than the tightest one: a 100 x 100 x 2 plate rotated 30 degrees about Z reports 136.6 x 136.6 x 2, because any in-plane pair of axes is principal for a square plate.

      Parameters

      Returns Result<PrincipalBoundingBox>

      Result with the box center in world coordinates, orthonormal right-handed axes ordered by decreasing extent, and the full edge lengths along those axes. Fails with NOT_A_SOLID for any other shape type (face, wire, shell, ...), ZERO_VOLUME when the shape encloses no volume (e.g. a compound of faces), and an UNSUPPORTED error on kernels without an inertia query.

      const { size, axes, center } = unwrap(principalBoundingBox(board));
      // size: [length, width, thickness]; axes[2] is the board's normal