Box
-
class
compas.geometry.
Box
(frame, xsize, ysize, zsize)[source] Bases:
compas.geometry.shapes._shape.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 (
compas.geometry.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 (compas.geometry.Frame) – The local coordinate system of the box.
xsize (float) – The size of the box in the local X direction.
ysize (float) – The size of the box in the local Y direction.
zsize (float) – The size of the box in the local Z direction.
width (read-only) (float) – Alias for
xsize
.depth (read-only) (float) – Alias for
ysize
.height (read-only) (float) – Alias for
zsize
.diagonal (read-only) (tuple of compas.geometry.Point) – The start and end point of the main diagonal of the box.
dimensions (read-only) (list of float) – List of sizes in local coordinate directions.
area (read-only) (float) – The surface area of the box.
volume (read-only) (float) – The volume of the box.
vertices (read-only) (list of list) – The XYZ coordinates of the corners of the box. With respect to the local Z axis, the vertices of the bottom face are listed first in clockwise direction, starting at the bottom left corner. The vertices of the top face are listed in counterclockwise direction.
faces (read-only) (list of list) – The vertices of the faces of the box. The cycle directions of the faces are such that face normals point outwards.
Examples
>>> box = Box(Frame.worldXY(), 1.0, 2.0, 3.0)
Methods
__init__
(frame, xsize, ysize, zsize)Initialize self.
contains
(point)Verify if the box contains a given point.
copy
()Makes a copy of this primitive.
from_bounding_box
(bbox)Construct a box from the result of a bounding box calculation.
from_corner_corner_height
(corner1, corner2, …)Construct a box from the opposite corners of its base and its height.
from_data
(data)Construct a box from its data representation.
from_diagonal
(diagonal)Construct a box from its main diagonal.
from_json
(filepath)Construct a primitive from structured data contained in a json file.
from_width_height_depth
(width, height, depth)Construct a box from its width, height and depth.
to_data
()Returns the data dictionary that represents the primitive.
to_json
(filepath)Serialise the structured data representing the primitive to json.
Returns a list of vertices and faces.
transform
(transformation)Transform the box.
transformed
(transformation)Returns a transformed copy of this primitive.
Validate the data of this object against its data schema (self.DATASCHEMA).
Validate the data loaded from a JSON representation of the data of this object against its data schema (self.DATASCHEMA).