Bounding Boxes
Description
Every mobject has a "bounding box", which is the smallest rectangle that surrounds it completely.
Details
Under the hood, spatial relations use the bounding boxes of the mobjects in the operation. These same operations are commonly useful for adding labels or arrows or dots at specific locations on the bbox. The "complete" bounding box is represented as 9 points: 4 corners, 4 edge points, and 1 center.
The bounding box points for a mobject can be accessed in the following ways:
mobject.right
: the midpoint on the right edgemobject.left
: the midpoint on the left edgemobject.top
: the midpoint on the top edgemobject.bottom
: the midpoint on the bottom edgemobject.center
: the center of the bboxmobject.get_corner(UR)
: upper right cornermobject.get_corner(UL)
: upper left cornermobject.get_corner(DL)
: down (lower) left cornermobject.get_corner(DR)
: down (lower) right corner
These operations return a Point3D
(e.g. [1, 0, 0])
The width and height of the bbox can also be accessed as mobject.width
and mobject.height
respectively.