colour.geometry.hull_section#
- colour.geometry.hull_section(hull: trimesh.Trimesh, axis: Literal['+z', '+x', '+y'] | str = '+z', origin: float = 0.5, normalise: bool = False) NDArrayFloat[source]#
Compute the hull section for the specified axis at the specified origin.
Generate a cross-sectional contour of a 3D hull by intersecting it with a plane perpendicular to the specified axis at the specified origin coordinate. This operation produces vertices that define the boundary of the hull’s intersection with the cutting plane.
- Parameters:
hull (trimesh.Trimesh) – Trimesh hull object representing the 3D geometry to section.
axis (Literal['+z', '+x', '+y'] | str) – Axis perpendicular to which the hull section will be computed. Options are “+x”, “+y”, or “+z”.
origin (float) – Coordinate along
axisat which to compute the hull section. The value represents either an absolute position or a normalised position depending on thenormaliseparameter.normalise (bool) – Whether to normalise the
origincoordinate to the extent of the hull along the specifiedaxis. WhenTrue,originis interpreted as a value in [0, 1] where 0 represents the minimum extent and 1 represents the maximum extent alongaxis.
- Returns:
Hull section vertices forming a closed contour. The vertices are ordered to form a continuous path around the section boundary.
- Return type:
- Raises:
ValueError – If no section exists on the specified axis at the specified origin, typically when the cutting plane does not intersect the hull.
Examples
>>> from colour.geometry import primitive_cube >>> from colour.utilities import is_trimesh_installed >>> vertices, faces, outline = primitive_cube(1, 1, 1, 2, 2, 2) >>> if is_trimesh_installed: ... import trimesh ... ... hull = trimesh.Trimesh(vertices["position"], faces, process=False) ... hull_section(hull, origin=0) array([[-0. , -0.5, 0. ], [ 0.5, -0.5, 0. ], [ 0.5, 0. , -0. ], [ 0.5, 0.5, -0. ], [-0. , 0.5, 0. ], [-0.5, 0.5, 0. ], [-0.5, 0. , -0. ], [-0.5, -0.5, -0. ], [-0. , -0.5, 0. ]])