File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
otary/geometry/discrete/shape Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -337,8 +337,9 @@ def is_regular(self, margin_dist_error_pct: float = 1e-2) -> bool:
337337 diag2 = Segment (points = self .asarray [diag2_idxs ])
338338
339339 # rectangular criteria = the diagonals have same lengths
340- normed_length = np .sqrt (diag1 .length * diag2 .length )
341- if np .abs (diag1 .length - diag2 .length ) > normed_length * margin_dist_error_pct :
340+ normed_length = (diag1 .length + diag2 .length ) / 2
341+ err_tol = normed_length * margin_dist_error_pct
342+ if np .abs (diag1 .length - diag2 .length ) > err_tol :
342343 return False
343344
344345 # there should exist only one intersection point
@@ -351,8 +352,8 @@ def is_regular(self, margin_dist_error_pct: float = 1e-2) -> bool:
351352 dist_mid_cross_diag1 = np .linalg .norm (cross_point - diag1 .centroid )
352353 dist_mid_cross_diag2 = np .linalg .norm (cross_point - diag2 .centroid )
353354 if (
354- np . abs ( dist_mid_cross_diag1 ) > normed_length * margin_dist_error_pct
355- or np . abs ( dist_mid_cross_diag2 ) > normed_length * margin_dist_error_pct
355+ dist_mid_cross_diag1 > err_tol
356+ or dist_mid_cross_diag2 > err_tol
356357 ):
357358 return False
358359
You can’t perform that action at this time.
0 commit comments