colour.geometry.primitive_cube#

colour.geometry.primitive_cube(width: float = 1, height: float = 1, depth: float = 1, width_segments: int = 1, height_segments: int = 1, depth_segments: int = 1, planes: Literal['-x', '+x', '-y', '+y', '-z', '+z', 'xy', 'xz', 'yz', 'yx', 'zx', 'zy'] | None = None, dtype_vertices: Type[DTypeFloat] | None = None, dtype_indexes: Type[DTypeInt] | None = None) Tuple[ndarray[Any, dtype[_ScalarType_co]], ndarray[Any, dtype[_ScalarType_co]], ndarray[Any, dtype[_ScalarType_co]]][source]#

Generate vertices and indexes for a filled and outlined cube primitive.

Parameters:
  • width (float) – Cube width.

  • height (float) – Cube height.

  • depth (float) – Cube depth.

  • width_segments (int) – Cube segments count along the width.

  • height_segments (int) – Cube segments count along the height.

  • depth_segments (int) – Cube segments count along the depth.

  • planes (Literal['-x', '+x', '-y', '+y', '-z', '+z', 'xy', 'xz', 'yz', 'yx', 'zx', 'zy'] | None) – Grid primitives to include in the cube construction.

  • dtype_vertices (Type[DTypeFloat] | None) – numpy.dtype to use for the grid vertices, default to the numpy.dtype defined by the colour.constant.DTYPE_FLOAT_DEFAULT attribute.

  • dtype_indexes (Type[DTypeInt] | None) – numpy.dtype to use for the grid indexes, default to the numpy.dtype defined by the colour.constant.DTYPE_INT_DEFAULT attribute.

Returns:

Tuple of cube vertices, face indexes to produce a filled cube and outline indexes to produce an outline of the faces of the cube.

Return type:

tuple

Examples

>>> vertices, faces, outline = primitive_cube()
>>> print(vertices)
[([-0.5,  0.5, -0.5], [ 0.,  1.], [-0., -0., -1.], [ 0.,  1.,  0.,  1.])
 ([ 0.5,  0.5, -0.5], [ 1.,  1.], [-0., -0., -1.], [ 1.,  1.,  0.,  1.])
 ([-0.5, -0.5, -0.5], [ 0.,  0.], [-0., -0., -1.], [ 0.,  0.,  0.,  1.])
 ([ 0.5, -0.5, -0.5], [ 1.,  0.], [-0., -0., -1.], [ 1.,  0.,  0.,  1.])
 ([-0.5,  0.5,  0.5], [ 0.,  1.], [ 0.,  0.,  1.], [ 0.,  1.,  1.,  1.])
 ([ 0.5,  0.5,  0.5], [ 1.,  1.], [ 0.,  0.,  1.], [ 1.,  1.,  1.,  1.])
 ([-0.5, -0.5,  0.5], [ 0.,  0.], [ 0.,  0.,  1.], [ 0.,  0.,  1.,  1.])
 ([ 0.5, -0.5,  0.5], [ 1.,  0.], [ 0.,  0.,  1.], [ 1.,  0.,  1.,  1.])
 ([ 0.5, -0.5, -0.5], [ 0.,  1.], [-0., -1., -0.], [ 1.,  0.,  0.,  1.])
 ([ 0.5, -0.5,  0.5], [ 1.,  1.], [-0., -1., -0.], [ 1.,  0.,  1.,  1.])
 ([-0.5, -0.5, -0.5], [ 0.,  0.], [-0., -1., -0.], [ 0.,  0.,  0.,  1.])
 ([-0.5, -0.5,  0.5], [ 1.,  0.], [-0., -1., -0.], [ 0.,  0.,  1.,  1.])
 ([ 0.5,  0.5, -0.5], [ 0.,  1.], [ 0.,  1.,  0.], [ 1.,  1.,  0.,  1.])
 ([ 0.5,  0.5,  0.5], [ 1.,  1.], [ 0.,  1.,  0.], [ 1.,  1.,  1.,  1.])
 ([-0.5,  0.5, -0.5], [ 0.,  0.], [ 0.,  1.,  0.], [ 0.,  1.,  0.,  1.])
 ([-0.5,  0.5,  0.5], [ 1.,  0.], [ 0.,  1.,  0.], [ 0.,  1.,  1.,  1.])
 ([-0.5, -0.5,  0.5], [ 0.,  1.], [-1., -0., -0.], [ 0.,  0.,  1.,  1.])
 ([-0.5,  0.5,  0.5], [ 1.,  1.], [-1., -0., -0.], [ 0.,  1.,  1.,  1.])
 ([-0.5, -0.5, -0.5], [ 0.,  0.], [-1., -0., -0.], [ 0.,  0.,  0.,  1.])
 ([-0.5,  0.5, -0.5], [ 1.,  0.], [-1., -0., -0.], [ 0.,  1.,  0.,  1.])
 ([ 0.5, -0.5,  0.5], [ 0.,  1.], [ 1.,  0.,  0.], [ 1.,  0.,  1.,  1.])
 ([ 0.5,  0.5,  0.5], [ 1.,  1.], [ 1.,  0.,  0.], [ 1.,  1.,  1.,  1.])
 ([ 0.5, -0.5, -0.5], [ 0.,  0.], [ 1.,  0.,  0.], [ 1.,  0.,  0.,  1.])
 ([ 0.5,  0.5, -0.5], [ 1.,  0.], [ 1.,  0.,  0.], [ 1.,  1.,  0.,  1.])]
>>> print(faces)
[[ 1  2  0]
 [ 1  3  2]
 [ 4  6  5]
 [ 6  7  5]
 [ 9 10  8]
 [ 9 11 10]
 [12 14 13]
 [14 15 13]
 [17 18 16]
 [17 19 18]
 [20 22 21]
 [22 23 21]]
>>> print(outline)
[[ 0  2]
 [ 2  3]
 [ 3  1]
 [ 1  0]
 [ 4  6]
 [ 6  7]
 [ 7  5]
 [ 5  4]
 [ 8 10]
 [10 11]
 [11  9]
 [ 9  8]
 [12 14]
 [14 15]
 [15 13]
 [13 12]
 [16 18]
 [18 19]
 [19 17]
 [17 16]
 [20 22]
 [22 23]
 [23 21]
 [21 20]]