Polyline.divide_by_length
- Polyline.divide_by_length(length, strict=True, tol=1e-06)[source]
Divide 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.Point
]
- list[
Notes
The points of the new polyline are constrained to the segments of the old polyline. However, since the old points are not part of the new set of points, the geometry of the polyline will change.
Examples
>>> polyline = Polyline([(0, 0, 0), (1, 1, 0), (2, 3, 0), (4, 4, 0), (5, 2, 0)]) >>> divided_polylines = polyline.divide_by_length(3) >>> divided_polyline [Point(0.000, 0.000, 0.000), Point(1.709, 2.418, 0.000), Point(4.051, 3.898, 0.000)]
>>> polyline = Polyline([(0, 0, 0), (1, 1, 0), (2, 3, 0), (4, 4, 0), (5, 2, 0)]) >>> divided_polylines = polyline.divide_by_length(3, strict=False) >>> divided_polyline [Point(0.000, 0.000, 0.000), Point(1.709, 2.418, 0.000), Point(4.051, 3.898, 0.000), Point(5.000, 2.000, 0.000)]