Box
- class compas.geometry.Box(frame, xsize, ysize, zsize, **kwargs)[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)
Attributes
DATASCHEMA
The schema of the data of this object.
JSONSCHEMANAME
area
The surface area of the box.
back
bottom
data
Returns the data dictionary that represents the box.
depth
The depth of the box in y direction.
diagonal
dimensions
edges
faces
The faces of the box defined as lists of vertex indices.
frame
The box's frame.
front
height
The height of the box in z direction.
left
points
right
top
vertices
The XYZ coordinates of the vertices of the box.
volume
The volume of the box.
width
The width of the box in x direction.
xmax
xmin
xsize
The size of the box in the box frame's x direction.
ymax
ymin
ysize
The size of the box in the box frame's y direction.
zmax
zmin
zsize
The size of the box in the box frame's z direction.
Inherited Attributes
JSONSCHEMA
The schema of the JSON representation of the data of this object.
dtype
The type of the object in the form of a '2-level' import and a class name.
guid
The globally unique identifier of the object.
jsondefinitions
Reusable schema definitions.
jsonstring
The representation of the object data in JSON format.
jsonvalidator
JSON schema validator for draft 7.
name
The 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).