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

contains

Verify if the box contains a given point.

from_bounding_box

Construct a box from the result of a bounding box calculation.

from_corner_corner_height

Construct a box from the opposite corners of its base and its height.

from_data

Construct a box from its data representation.

from_diagonal

Construct a box from its main diagonal.

from_width_height_depth

Construct a box from its width, height and depth.

to_vertices_and_faces

Returns a list of vertices and faces.

transform

Transform the box.

Inherited Methods

ToString

Converts the instance to a string.

copy

Make an independent copy of the data object.

from_json

Construct an object from serialized data contained in a JSON file.

from_jsonstring

Construct an object from serialized data contained in a JSON string.

sha256

Compute a hash of the data for comparison during version control using the sha256 algorithm.

to_data

Convert an object to its native data representation.

to_json

Serialize the data representation of an object to a JSON file.

to_jsonstring

Serialize the data representation of an object to a JSON string.

transformed

Returns a transformed copy of this geometry.

validate_data

Validate the object's data against its data schema.

validate_json

Validate the object's data against its json schema.