pyrobopath.tools.geometry.segment_path#
- pyrobopath.tools.geometry.segment_path(path: List[ndarray], max_length: float) List[List[ndarray]][source]#
Segments a continuous path into multiple shorter sub-paths constrained by a maximum length.
This function takes a list of 3D points representing a path and divides it into sub-paths such that the arc length of each sub-path does not exceed max_length. If needed, intermediate points are interpolated along the path to achieve accurate segmentation.
- Parameters:
path (List[np.ndarray]) – A list of 3D NumPy arrays representing the points of a continuous path.
max_length (float) – The maximum allowed length of each resulting segment
- Returns:
A list of sub-paths, where each sub-path is itself a list of 3D points, and each sub-path’s length is less than or equal to max_length.
- Return type:
List[List[np.ndarray]]
Examples
>>> path = [np.array([0.0, 0.0, 0.0]), np.array([2.0, 0.0, 0.0]), ... np.array([10.0, 0.0, 0.0])] >>> segment_path(path, max_length=7) [[array([0., 0., 0.]), array([2., 0., 0.]), array([5., 0., 0.])], [array([5., 0., 0.]), array([10., 0., 0.])]]