Box
- class compas.geometry.Box(frame, xsize, ysize, zsize, **kwargs)[source]
Bases:
compas.geometry.shapes._shape.ShapeA 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)Attributes
DATASCHEMAThe schema of the data of this object.
JSONSCHEMANAMEareaThe surface area of the box.
backbottomdataReturns the data dictionary that represents the box.
depthThe depth of the box in y direction.
diagonaldimensionsedgesfacesThe faces of the box defined as lists of vertex indices.
frameThe box's frame.
frontheightThe height of the box in z direction.
leftpointsrighttopverticesThe XYZ coordinates of the vertices of the box.
volumeThe volume of the box.
widthThe width of the box in x direction.
xmaxxminxsizeThe size of the box in the box frame's x direction.
ymaxyminysizeThe size of the box in the box frame's y direction.
zmaxzminzsizeThe size of the box in the box frame's z direction.
Inherited Attributes
JSONSCHEMAThe schema of the JSON representation of the data of this object.
dtypeThe type of the object in the form of a '2-level' import and a class name.
guidThe globally unique identifier of the object.
jsondefinitionsReusable schema definitions.
jsonstringThe representation of the object data in JSON format.
jsonvalidatorJSON schema validator for draft 7.
nameThe name of the object.
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
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.
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 (self.DATASCHEMA).
Validate the object's data against its json schema (self.JSONSCHEMA).