colour.geometry.primitive_grid¶
- colour.geometry.primitive_grid(width: Floating = 1, height: Floating = 1, width_segments: Integer = 1, height_segments: Integer = 1, axis: Literal['-x', '+x', '-y', '+y', '-z', '+z', 'xy', 'xz', 'yz', 'yx', 'zx', 'zy'] = '+z', dtype_vertices: Optional[Type[DTypeFloating]] = None, dtype_indexes: Optional[Type[DTypeInteger]] = None) Tuple[NDArray, NDArray, NDArray] [source]¶
Generate vertices and indexes for a filled and outlined grid primitive.
- Parameters
width (Floating) – Grid width.
height (Floating) – Grid height.
width_segments (Integer) – Grid segments count along the width.
height_segments (Integer) – Grid segments count along the height.
axis (Literal[('-x', '+x', '-y', '+y', '-z', '+z', 'xy', 'xz', 'yz', 'yx', 'zx', 'zy')]) – Axis the primitive will be normal to, or plane the primitive will be co-planar with.
dtype_vertices (Optional[Type[DTypeFloating]]) –
numpy.dtype
to use for the grid vertices, default to thenumpy.dtype
defined by thecolour.constant.DEFAULT_FLOAT_DTYPE
attribute.dtype_indexes (Optional[Type[DTypeInteger]]) –
numpy.dtype
to use for the grid indexes, default to thenumpy.dtype
defined by thecolour.constant.DEFAULT_INT_DTYPE
attribute.
- Returns
Tuple of grid vertices, face indexes to produce a filled grid and outline indexes to produce an outline of the faces of the grid.
- Return type
References
[Cab]
Examples
>>> vertices, faces, outline = primitive_grid() >>> print(vertices) [([-0.5, 0.5, 0. ], [ 0., 1.], [ 0., 0., 1.], [ 0., 1., 0., 1.]) ([ 0.5, 0.5, 0. ], [ 1., 1.], [ 0., 0., 1.], [ 1., 1., 0., 1.]) ([-0.5, -0.5, 0. ], [ 0., 0.], [ 0., 0., 1.], [ 0., 0., 0., 1.]) ([ 0.5, -0.5, 0. ], [ 1., 0.], [ 0., 0., 1.], [ 1., 0., 0., 1.])] >>> print(faces) [[0 2 1] [2 3 1]] >>> print(outline) [[0 2] [2 3] [3 1] [1 0]]