@@ -266,7 +266,7 @@ def transform(self, T):
266266 def split_at_corners (self , angle_threshold ):
267267 """Splits a polyline at corners larger than the given angle_threshold
268268
269- Parameters:
269+ Parameters
270270 -----------
271271 angle_threshold : float
272272 In radians.
@@ -311,7 +311,7 @@ def split_at_corners(self, angle_threshold):
311311 def tangent_at_point_on_polyline (self , point ):
312312 """Calculates the tangent vector of a point on a polyline
313313
314- Parameters:
314+ Parameters
315315 -----------
316316 point: :class:`compas.geometry.Point`
317317
@@ -327,7 +327,7 @@ def tangent_at_point_on_polyline(self, point):
327327 def divide_polyline (self , num_segments ):
328328 """Divide a polyline in equal segments.
329329
330- Parameters:
330+ Parameters
331331 -----------
332332 num_segments : int
333333
@@ -340,16 +340,19 @@ def divide_polyline(self, num_segments):
340340
341341 return self .divide_polyline_by_length (segment_length , False )
342342
343- def divide_polyline_by_length (self , length , strict = True ):
344- """Splits a polyline in segments of a given length
343+ def divide_polyline_by_length (self , length , strict = True , tol = 1e-06 ):
344+ """Splits a polyline in segments of a given length.
345345
346- Parameters:
346+ Parameters
347347 -----------
348348 length : float
349349
350350 strict : bool
351351 If set to ``False``, the remainder segment will be added even if it is smaller than the desired length
352352
353+ tol : float
354+ floating point error tolerance
355+
353356 Returns
354357 -------
355358 list
@@ -379,7 +382,7 @@ def divide_polyline_by_length(self, length, strict=True):
379382
380383 if strict is False and not self .is_closed () and len (division_pts ) < num_pts + 1 :
381384 division_pts .append (new_polyline .points [- 1 ])
382- elif strict is False and division_pts [- 1 ] != self .points [- 1 ]:
385+ elif strict is False and division_pts [- 1 ]. distance_to_point ( self .points [- 1 ]) > tol :
383386 division_pts .append (self .points [- 1 ])
384387
385388 return division_pts
0 commit comments