BoundingBox — Aspose.3D FOSS for Python API Reference

Overview

BoundingBox is an axis-aligned bounding box (AABB) defined by two Vector3 corners: minimum (lowest x, y, z) and maximum (highest x, y, z). It is used for spatial queries such as point-in-box tests, frustum culling helpers, and scene-level size estimation.

A BoundingBox can be in a null (empty/uninitialised) state when created with no arguments. Calling merge() on a null box initialises it from the first point or box provided.

Package: aspose.threed.utilities

from aspose.threed.utilities import BoundingBox, Vector3

Constructor

SignatureDescription
BoundingBox()Null (empty) bounding box
BoundingBox(minimum, maximum)Constructs from two Vector3 corners
BoundingBox(min_x, min_y, min_z, max_x, max_y, max_z)Constructs from six scalar values

Properties

NameTypeDescription
minimumVector3The corner with the smallest x, y, z values. Returns (+inf, +inf, +inf) for a null box
maximumVector3The corner with the largest x, y, z values. Returns (-inf, -inf, -inf) for a null box
centerVector3Midpoint between minimum and maximum; (0,0,0) for a null box
sizeVector3Extent per axis (maximum - minimum); (0,0,0) for a null box

Static Factory Methods

MethodReturn TypeDescription
BoundingBox.get_null()BoundingBoxReturns a null (empty) bounding box
BoundingBox.get_infinite()BoundingBoxReturns an infinite bounding box spanning all of space

Instance Methods

MethodReturn TypeDescription
merge(point)NoneExpands the box to include a Vector3, Vector4, or another BoundingBox
merge(x, y, z)NoneExpands the box to include the point (x, y, z)
contains(point)boolReturns True if the Vector3 point is inside or on the boundary
contains(box)boolReturns True if box is entirely within this box
overlaps_with(box)boolReturns True if the two boxes intersect
scale()floatReturns the largest absolute coordinate value — useful as a rough scene scale estimate

Example

from aspose.threed.utilities import BoundingBox, Vector3

# Build a bounding box from a list of points
bb = BoundingBox()
points = [
    Vector3(0.0, 0.0, 0.0),
    Vector3(1.0, 2.0, 3.0),
    Vector3(-1.0, 0.5, 1.5),
]
for p in points:
    bb.merge(p)

print(bb.minimum)   # Vector3(-1.0, 0.0, 0.0)
print(bb.maximum)   # Vector3(1.0, 2.0, 3.0)
print(bb.center)    # Vector3(0.0, 1.0, 1.5)
print(bb.size)      # Vector3(2.0, 2.0, 3.0)

# Point containment
print(bb.contains(Vector3(0.5, 1.0, 1.5)))   # True
print(bb.contains(Vector3(5.0, 0.0, 0.0)))   # False

# Box containment
inner = BoundingBox(Vector3(0, 0, 0), Vector3(0.5, 0.5, 0.5))
print(bb.contains(inner))   # True

# Overlap test
other = BoundingBox(Vector3(0.5, 0.5, 0.5), Vector3(2.0, 2.0, 2.0))
print(bb.overlaps_with(other))   # True

# Retrieve from a node
from aspose.threed import Scene
from aspose.threed.entities import Mesh
from aspose.threed.utilities import Vector4

scene = Scene()
mesh = Mesh()
mesh.control_points.append(Vector4(-1, 0, 0, 1))
mesh.control_points.append(Vector4( 1, 0, 0, 1))
mesh.control_points.append(Vector4( 0, 1, 0, 1))
mesh.create_polygon(0, 1, 2)
node = scene.root_node.create_child_node("tri", mesh)
node_bb = node.get_bounding_box()
print(node_bb.minimum)
print(node_bb.maximum)

See Also