File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
tests/compas/datastructures Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -1070,6 +1070,8 @@ def test_normal():
10701070
10711071
10721072def test_volume():
1073+ import math
1074+
10731075 # Test with a cube
10741076 mesh = Mesh.from_stl(compas.get("cube_binary.stl"))
10751077 volume = mesh.volume()
@@ -1089,6 +1091,14 @@ def test_volume():
10891091 assert volume is not None
10901092 assert volume > 0
10911093
1094+ # Test with a sphere approximation
1095+ sphere_mesh = Mesh.from_shape(Sphere(radius=1.0), u=32, v=32)
1096+ volume = sphere_mesh.volume()
1097+ assert volume is not None
1098+ expected_sphere_volume = (4.0/3.0) * math.pi * (1.0 ** 3)
1099+ # Allow for ~1% error due to discretization
1100+ assert TOL.is_close(volume, expected_sphere_volume, rtol=0.02)
1101+
10921102 # Test with an open mesh (should return None)
10931103 mesh = Mesh.from_obj(compas.get("faces.obj"))
10941104 volume = mesh.volume()
You can’t perform that action at this time.
0 commit comments