Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased


### Added

* Added Python 3.9 support.
Expand All @@ -19,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

* Fixed box scaling.
* Fixed a bug in `Polyline.divide_polyline_by_length` related to a floating point rounding error.

### Removed

Expand Down
17 changes: 10 additions & 7 deletions src/compas/geometry/primitives/polyline.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ def transform(self, T):
def split_at_corners(self, angle_threshold):
"""Splits a polyline at corners larger than the given angle_threshold

Parameters:
Parameters
-----------
angle_threshold : float
In radians.
Expand Down Expand Up @@ -311,7 +311,7 @@ def split_at_corners(self, angle_threshold):
def tangent_at_point_on_polyline(self, point):
"""Calculates the tangent vector of a point on a polyline

Parameters:
Parameters
-----------
point: :class:`compas.geometry.Point`

Expand All @@ -327,7 +327,7 @@ def tangent_at_point_on_polyline(self, point):
def divide_polyline(self, num_segments):
"""Divide a polyline in equal segments.

Parameters:
Parameters
-----------
num_segments : int

Expand All @@ -340,16 +340,19 @@ def divide_polyline(self, num_segments):

return self.divide_polyline_by_length(segment_length, False)

def divide_polyline_by_length(self, length, strict=True):
"""Splits a polyline in segments of a given length
def divide_polyline_by_length(self, length, strict=True, tol=1e-06):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add tol to the parameters list in the docstring, please...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, also, there shouldn't be blank lines between the parameters... it makes the docs look funny... see https://compas.dev/compas/latest/api/generated/compas.geometry.Polyline.divide_polyline_by_length.html#compas.geometry.Polyline.divide_polyline_by_length

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just fyi, in offset_polyline tol isn't referenced!

def offset_polyline(polyline, distance, normal=[0.0, 0.0, 1.0], tol=1e-6):

Will make the changes though!

"""Splits a polyline in segments of a given length.

Parameters:
Parameters
-----------
length : float

strict : bool
If set to ``False``, the remainder segment will be added even if it is smaller than the desired length

tol : float
floating point error tolerance

Returns
-------
list
Expand Down Expand Up @@ -379,7 +382,7 @@ def divide_polyline_by_length(self, length, strict=True):

if strict is False and not self.is_closed() and len(division_pts) < num_pts+1:
division_pts.append(new_polyline.points[-1])
elif strict is False and division_pts[-1] != self.points[-1]:
elif strict is False and division_pts[-1].distance_to_point(self.points[-1]) > tol:
division_pts.append(self.points[-1])

return division_pts
Expand Down