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

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

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.

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 (self.DATASCHEMA).

validate_json

Validate the object's data against its json schema (self.JSONSCHEMA).