5.9. boundingbox — An axis-aligned bounding box

class cgkit.boundingbox.BoundingBox([b1, b2])

b1 and b2 are the initial bounds (as vec3) of the bounding box. Everything that lies within the specified box (including the bounds) is considered inside the bounding box. If you don’t specify any bounds the bounding box is initially empty.


Make the bounding box empty.


Return True if the bounding box is empty.


Return the minimum and maximum bound. The bounds are returned as vec3 objects. The optional vec3 argument dir specifies which corners are actually returned. When viewed along a ray with the given direction the minimum bound always comes before the maximum bound.

BoundingBox.setBounds(b1, b2)

Set new bounds for the bounding box. The rectangle given by b1 and b2 defines the new bounding box.


Return the center of the bounding box (i.e. 0.5*(bmin+bmax)). The null vector is returned if the bounding box is empty.


Enlarge the bounding box so that the point p is enclosed in the box.


Enlarge the bounding box so that the bounding box bb is enclosed in the box.


Returns a transformed bounding box. The transformation is given by M which must be a mat4. The result will still be axis aligned, so the volume will not be preserved.


Clamp the point p so that it lies within the bounding box. Each axis is clamped against the corresponding bounding box interval.

Previous topic

5.8. cmds — Scene-specific commands

Next topic

5.10. joystick — Joystick support

This Page