Skip to content

Updated integral_mean_curvature function #2416

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 11, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
added test_IMCtorus to test for concave shapes
  • Loading branch information
yajushikhurana committed Jun 10, 2025
commit 24cd64b66e1179148d8dfa8c5b976fb979c9ec08
13 changes: 13 additions & 0 deletions tests/test_integralmeancurvature.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@ def test_IMCbox(self):
ref = 4 * extent.sum() * g.np.pi / 2 * 0.5
assert g.np.isclose(IMC, ref, rtol=tol)

def test_IMCtorus(self):
# how close do we need to be - relative tolerance
tol = 1e-2
r = 1.1
for aspect_ratio in [1.1, 2.1, 4.0, 10.0]:
R = r * aspect_ratio
m = g.trimesh.creation.torus(
major_radius=R, minor_radius=r, major_sections=100, minor_sections=100
)
IMC = m.integral_mean_curvature
ref = 2 * (g.np.pi**2) * R
assert g.np.isclose(IMC, ref, rtol=tol)


if __name__ == "__main__":
g.trimesh.util.attach_to_log()
Expand Down
2 changes: 1 addition & 1 deletion trimesh/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1437,7 +1437,7 @@ def face_adjacency_angles(self) -> NDArray[float64]:
# find the angle between the pairs of vectors
angles = geometry.vector_angle(pairs)
return angles

@cache_decorator
def face_adjacency_angles_with_sign(self) -> NDArray[float64]:
"""
Expand Down
1 change: 1 addition & 0 deletions trimesh/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ def vector_angle(pairs):

return angles


def vector_angle_with_sign(mesh):
"""
Find the signed angles between between adjacent face normals in a mesh.
Expand Down