m3sh.traits#

Geometric mesh traits.

Convenience functions to compute common and often used geometric mesh traits like normals (see, e.g., [1]) and curvature (see [2]).

Important

Functions defined in this module are only applicable to meshes in Euclidean 3-space, i.e., meshes with vertex coordinate array of shape (n, 3). They cannot be applied to 2-manifold meshes embedded in higher dimensional space.

Example#

Face normals of a mesh can be computed as

>>> normals = traits.face_normals(mesh)

Since faces can be used as an index, the normal of a face can be accessed as normals[f] or more verbosely as normals[f.index]. Instead of passing around the pair (mesh, normals), we can add the normals array to the mesh as an attribute:

>>> mesh.add_face_data('face_normals', 'normal', normals)

In addition to just adding the array as an attribute this also add a property to each face of the mesh that makes the corresponding face normal accessible as f.normal. The normals array can still be accessed directly as mesh.face_normals. In particular

>>> mesh.face_normals is normals
True

References#

[1]

S. Jin, R. Lewis, and D. West: A comparison of algorithms for vertex normal computation, The Visual Computer 21, 2005.

[2]

M. Meyer et al.: Discrete differential-geometry operators for triangulated 2-manifolds, in HC. Hege, K. Polthier (eds) Visualization and Mathematics III, 2003.

Functions

area(mesh)

Surface area of triangle mesh.

axis_angles(mesh[, normals])

Rotation parameters.

cotan_weight(halfedge[, boundary, clamp])

Cotangent weight.

cotan_weights(mesh[, boundary, clamp])

Cotangent weights.

diameter(points)

Diameter of a point set.

dihedral_angle(halfedge[, degrees])

Dihedral angle.

dihedral_angles(mesh[, normals, degrees])

Dihedral angles.

edge_stats(item)

Edge length statistics.

face_area(face)

Area of triangular face.

face_frame(face[, normal, axis])

Canonical frame of a face.

face_normal(face)

Face normal vector.

face_normals(mesh)

Face normals.

gauss_curvature(vertex)

Gaussian curvature estimate.

gauss_curvatures(mesh[, weights])

Gaussian curvate estimate.

laplace_matrix(mesh[, weights, normalize])

Laplace matrix.

mean_curvature(vertex[, normal])

Mean curvature estimate.

mean_curvature_vector(vertex)

Mean curvature vector.

mean_curvature_vectors(mesh[, weights])

Mean curvature vectors.

mean_curvatures(mesh[, mcvs, normals])

Mean curvature estimates.

principal_curvature(vertex[, normal])

Principal curvature estimate.

vertex_angle(vertex)

Total angle around a vertex.

vertex_area(vertex)

Vertex area.

vertex_areas(mesh[, weights])

Mixed vertex areas.

vertex_normal(vertex[, weight])

Vertex normal.

vertex_normals(mesh[, weight, broadcast])

Vertex normals.