Skip to content

Commit 9b70d27

Browse files
committed
Revert "Increased resilience of minimal_bounding_sphere method"
This reverts commit 40f500c, moving all miniball-related changes to #178.
1 parent 40f500c commit 9b70d27

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

coxeter/shapes/polyhedron.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -556,31 +556,21 @@ def minimal_bounding_sphere(self):
556556
'directly from PyPI using "pip install miniball".'
557557
)
558558

559-
# Define a check function to ensure points lie within a sphere
560-
def points_within_sphere(points, center, radius):
561-
return np.linalg.norm(points - center, axis=1) <= radius
562-
563559
# The algorithm in miniball involves solving a linear system and
564560
# can therefore occasionally be somewhat unstable. Applying a
565-
# random rotation will usually fix the issue, and checking if
566-
# points lie inside will guarantee a correct answer.
567-
max_attempts = 20
561+
# random rotation will usually fix the issue.
562+
max_attempts = 10
568563
attempt = 0
569564
current_rotation = [1, 0, 0, 0]
570565
vertices = self.vertices
571566
while attempt < max_attempts:
572567
attempt += 1
573568
try:
574569
center, r2 = miniball.get_bounding_ball(vertices)
575-
assert np.all(points_within_sphere(vertices, center, np.sqrt(r2)))
576570
break
577571
except np.linalg.LinAlgError:
578572
current_rotation = rowan.random.rand(1)
579573
vertices = rowan.rotate(current_rotation, vertices)
580-
except AssertionError:
581-
print("Miniball sphere does not contain vertices. Retesting...")
582-
current_rotation = rowan.random.rand(1)
583-
vertices = rowan.rotate(current_rotation, vertices)
584574
else:
585575
raise RuntimeError("Unable to solve for a bounding sphere.")
586576

0 commit comments

Comments
 (0)