Box
- class compas.geometry.Box(frame, xsize, ysize, zsize, **kwargs)[source]
Bases:
Shape
A box is defined by a frame and its dimensions along the frame’s x-, y- and z-axes.
The center of the box is positioned at the origin of the coordinate system defined by the frame. The box is axis-aligned to the frame.
A box is a three-dimensional geometric shape with 8 vertices, 12 edges and 6 faces. The edges of a box meet at its vertices at 90 degree angles. The faces of a box are planar. Faces which do not share an edge are parallel.
- Parameters
frame (
Frame
) – The frame of the box.xsize (float) – The size of the box in the box frame’s x direction.
ysize (float) – The size of the box in the box frame’s y direction.
zsize (float) – The size of the box in the box frame’s z direction.
- Attributes
frame (
Frame
) – The box’s frame.xsize (float) – The size of the box in the box frame’s x direction.
ysize (float) – The size of the box in the box frame’s y direction.
ysize (float) – The size of the box in the box frame’s z direction.
xmin (float, read-only) – Minimum value along local X axis.
xmax (float, read-only) – Maximum value along local X axis.
ymin (float, read-only) – Minimum value along local Y axis.
ymax (float, read-only) – Maximum value along local Y axis.
zmin (float, read-only) – Minimum value along local Z axis.
zmax (float, read-only) – Maximum value along local Z axis.
width (float, read-only) – The width of the box in X direction.
depth (float, read-only) – The depth of the box in Y direction.
height (float, read-only) – The height of the box in Z direction.
diagonal (
Line
, read-only) – Diagonal of the box.dimensions (list[float], read-only) – The dimensions of the box in the local frame.
area (float, read-only) – The surface area of the box.
volume (float, read-only) – The volume of the box.
points (list[
Point
], read-only) – The XYZ coordinates of the corners of the box.vertices (list[
Point
], read-only) – The XYZ coordinates of the vertices of the box.faces (list[list[int]], read-only) – The faces of the box defined as lists of vertex indices.
bottom (list[int], read-only) – The vertex indices of the bottom face.
front (list[int], read-only) – The vertex indices of the front face.
right (list[int], read-only) – The vertex indices of the right face.
back (list[int], read-only) – The vertex indices of the back face.
left (list[int], read-only) – The vertex indices of the left face.
top (list[int], read-only) – The vertex indices of the top face.
edges (list[tuple[int, int]], read-only) – The edges of the box as vertex index pairs.
Examples
>>> box = Box(Frame.worldXY(), 1.0, 2.0, 3.0)
Methods
Verify if the box contains a given point.
Construct a box from the result of a bounding box calculation.
Construct a box from the opposite corners of its base and its height.
Construct a box from its data representation.
Construct a box from its main diagonal.
Construct a box from its width, height and depth.
Returns a list of vertices and faces.
Transform the box.
Inherited Methods
Converts the instance to a string.
Make an independent copy of the data object.
Construct an object from serialized data contained in a JSON file.
Construct an object from serialized data contained in a JSON string.
Compute a hash of the data for comparison during version control using the sha256 algorithm.
Convert an object to its native data representation.
Serialize the data representation of an object to a JSON file.
Serialize the data representation of an object to a JSON string.
Returns a transformed copy of this geometry.
Validate the object's data against its data schema.
Validate the object's data against its json schema.