Polyline.split_by_length

Polyline.split_by_length(length, strict=True)[source]

Split a polyline in segments of a given length.

Parameters:
lengthfloat

Length of the segments.

strictbool, optional

If False, the remainder segment will be added even if it is smaller than the desired length

tolfloat, optional

Floating point error tolerance.

Returns:
list[compas.geometry.Polyline]

Examples

>>> from compas.geometry import Polyline
>>> polyline = Polyline([(0, 0, 0), (1, 1, 0), (2, 3, 0), (4, 4, 0), (5, 2, 0)])
>>> len(polyline.split_by_length(3))
2
>>> from compas.geometry import Polyline
>>> polyline = Polyline([(0, 0, 0), (1, 1, 0), (2, 3, 0), (4, 4, 0), (5, 2, 0)])
>>> len(polyline.split_by_length(3, strict=False))
3