Mesh algorithms¶
Surface area, volume, normals, curvature and spatial queries on a mesh store (Meshes). Each function splits a quad (a, b, c, d) into the triangles (a, b, c) and (a, c, d).
Function |
What it does |
Returns |
|---|---|---|
|
Totals for the level. |
|
|
Unit normal per vertex. |
|
|
Unsigned mean curvature per vertex (cotangent Laplace–Beltrami). |
|
|
Nearest point on the surface, searching outward one ring of chunks at a time. |
|
|
First surface hit along the ray. A zero |
|
Per-vertex rows are in store order, as read_mesh returns vertices. In the
query results, corners names the face found, each corner as (chunk, index in chunk). face_index is None when the face’s corners lie in more than one
chunk.
The example is a sphere of radius 10 centred on (20, 20, 20), with 642 vertices
and 1,280 triangles, ingested with --chunk-shape 20,20,20:
import numpy as np
from zarr_vectors_tools.algorithms import closest_point, compute_mean_curvature, compute_mesh_summary
s = compute_mesh_summary("sphere.zv")
s["surface_area"], s["volume"], s["euler_characteristic"] # 1250.65, 4152.74, 2
np.median(compute_mean_curvature("sphere.zv")["mean_curvature"]) # 0.0998: 1 / radius
closest_point("sphere.zv", np.array([45.0, 20.0, 20.0]))["position"] # [30. 20. 20.]