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
]
- list[
Examples
>>> from compas.geometry import Polyline >>> polyline = Polyline([(0, 0, 0), (1, 1, 0), (2, 3, 0), (4, 4, 0), (5, 2, 0)]) >>> split_polylines = polyline.split_polyline_by_length(3) >>> split_polylines [Polyline([Point(0.000, 0.000, 0.000), Point(1.000, 1.000, 0.000), Point(1.709, 2.418, 0.000)]), Polyline([Point(1.709, 2.418, 0.000), Point(2.000, 3.000, 0.000), Point(4.000, 4.000, 0.000), Point(4.051, 3.898, 0.000)])]
>>> from compas.geometry import Polyline >>> polyline = Polyline([(0, 0, 0), (1, 1, 0), (2, 3, 0), (4, 4, 0), (5, 2, 0)]) >>> split_polylines = polyline.split_polyline_by_length(3, strict=False) >>> split_polylines [Polyline([Point(0.000, 0.000, 0.000), Point(1.000, 1.000, 0.000), Point(1.709, 2.418, 0.000)]), Polyline([Point(1.709, 2.418, 0.000), Point(2.000, 3.000, 0.000), Point(4.000, 4.000, 0.000), Point(4.051, 3.898, 0.000)]), Polyline([Point(4.051, 3.898, 0.000), Point(5.000, 2.000, 0.000)])]