Box
- class compas.geometry.Box[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:
- xsizefloat
The size of the box in the box frame’s x direction.
- ysizefloat, optional
The size of the box in the box frame’s y direction. Defaults to the value of
xsize
.- zsizefloat, optional
The size of the box in the box frame’s z direction. Defaults to the value of
xsize
.- frame
compas.geometry.Frame
, optional The frame of the box. Defaults to
Frame.worldXY()
.- namestr, optional
The name of the shape.
Examples
>>> box = Box(1) >>> box.xsize 1.0 >>> box.ysize 1.0 >>> box.zsize 1.0 >>> box.volume 1.0 >>> box.area 6.0
>>> box = Box(1, 2, 3) >>> box.xsize 1.0 >>> box.ysize 2.0 >>> box.zsize 3.0 >>> box.volume 6.0 >>> box.area 22.0
- Attributes:
- areafloat, read-only
The surface area of the box.
- depthfloat, read-only
The depth of the box in Y direction.
- diagonal
compas.geometry.Line
, read-only Diagonal of the box.
- dimensionslist[float], read-only
The dimensions of the box in the local frame.
- frame
compas.geometry.Frame
The box’s frame.
- heightfloat, read-only
The height of the box in Z direction.
- volumefloat, read-only
The volume of the box.
- widthfloat, read-only
The width of the box in X direction.
- xminfloat, read-only
Minimum value along local X axis.
- xmaxfloat, read-only
Maximum value along local X axis.
- xsizefloat
The size of the box in the box frame’s x direction.
- yminfloat, read-only
Minimum value along local Y axis.
- ymaxfloat, read-only
Maximum value along local Y axis.
- ysizefloat
The size of the box in the box frame’s y direction.
- zminfloat, read-only
Minimum value along local Z axis.
- zmaxfloat, read-only
Maximum value along local Z axis.
- zsizefloat
The size of the box in the box frame’s z direction.
Methods
Verify if the box contains a given point.
Verify if the box contains the given points.
Return one of the eight corners of the box.
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 main diagonal.
Construct a box from a set of points.
Construct a box from its width, height and depth.
Scale the box.
Returns a BREP representation of the box.
Returns a mesh representation of the box.
Returns a list of vertices and faces.
Inherited Methods
Converts the instance to a string.
Compute the axis-aligned bounding box of the geometry.
Compute the oriented bounding box of the geometry.
Make an independent copy of the data object.
Construct an object of this type from a JSON file.
Construct an object of this type from a JSON string.
Rotate the shape.
Returns a rotated copy of this geometry.
Returns a scaled copy of this geometry.
Compute a hash of the data for comparison during version control using the sha256 algorithm.
Convert an object to its native data representation and save it to a JSON file.
Convert an object to its native data representation and save it to a JSON string.
Convert the shape to a polyhedron.
Transform the shape.
Returns a transformed copy of this geometry.
Translate the shape.
Returns a translated copy of this geometry.
Validate the data against the object's data schema.