Curvature¶
Mean curvature of a mesh's interfaces, from the cotangent Laplacian, as the Laplace pressure methods read it.
Curvatures are in inverse mesh length units. An interface all of whose vertices lie on junction
lines has no curvature (nan); see foambryo.pressure_inference.UndeterminedPressureWarning.
Sacha Ichbiah, 2021. Matthieu Perez, 2024.
compute_laplacian_cotan ¶
compute_laplacian_cotan(points: NDArray[float64], triangles: NDArray[int64]) -> tuple[NDArray[np.float64], NDArray[np.float64]]
Laplacian computation.
Consider a mesh M = (V, F), with verts of shape Nx3 and faces of shape Mx3. The Laplacian matrix L is a NxN matrix such that LV gives a matrix of vectors: LV[i] gives the normal scaled by the discrete mean curvature. For vertex i, assume S[i] is the set of neighboring vertices to i, a_ij and b_ij are the "outside" angles in the two triangles connecting vertex v_i and its neighboring vertex v_j for j in S[i], as seen in the diagram below. .. code-block:: python a_ij /\ / \ / \ / \ v_i /________\ v_j \ / \ / \ / \ / \/ b_ij The definition of the Laplacian is LV[i] = sum_j w_ij (v_j - v_i) For the uniform variant, w_ij = 1 / |S[i]| For the cotangent variant, w_ij = (cot a_ij + cot b_ij) / (sum_k cot a_ik + cot b_ik) For the cotangent curvature, w_ij = (cot a_ij + cot b_ij) / (4 A[i]) where A[i] is the sum of the areas of all triangles containing vertex v_i. There is a nice trigonometry identity to compute cotangents. Consider a triangle with side lengths A, B, C and angles a, b, c. .. code-block:: python c /|\ / | \ / | \ B / H| \ A / | \ / | \ /a_____|_____b\ C Then cot a = (B^2 + C^2 - A^2) / 4 * area We know that area = CH/2, and by the law of cosines we have A^2 = B^2 + C^2 - 2BC cos a => B^2 + C^2 - A^2 = 2BC cos a Putting these together, we get: B^2 + C^2 - A^2 2BC cos a _______________ = _________ = (B/H) cos a = cos a / sin a = cot a 4 * area 2CH [1] Desbrun et al, "Implicit fairing of irregular meshes using diffusion and curvature flow", SIGGRAPH 1999. [2] Nealan et al, "Laplacian Mesh Optimization", Graphite 2006.
compute_gaussian_curvature_vertices ¶
compute_gaussian_curvature_vertices(mesh: DcelData) -> NDArray[np.float64]
Return the discrete gaussian curvarture at every vertex of the mesh.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
DcelData
|
Mesh. |
required |
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
NDArray[np.float64]: Discrete gaussian curvature at every vertex of the mesh. |
compute_curvature_vertices_cotan ¶
compute_curvature_vertices_cotan(mesh: DcelData) -> tuple[NDArray[np.float64], NDArray[np.float64], NDArray[np.float64]]
Return the mean curvature at every vertex along with other unidentified data.
compute_curvature_interfaces ¶
compute_curvature_interfaces(mesh: DcelData, weighted: bool = True) -> dict[tuple[int, int], float]
Compute the mean curvature on the interfaces of the mesh.
The vertex mean curvature of the cotangent Laplacian, signed by the vertex normal, averaged over each interface's vertices that are not on a junction line.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
DcelData
|
the mesh. |
required |
weighted
|
bool
|
weight each vertex by its area ( |
True
|
Returns:
| Type | Description |
|---|---|
dict[tuple[int, int], float]
|
dict[tuple[int, int], float]: interface |
laplacian_cot ¶
laplacian_cot(points: NDArray[float64], triangles: NDArray[int64]) -> tuple[NDArray[np.float64], NDArray[np.float64]]
Returns the Laplacian matrix with cotangent weights and the inverse of the face areas.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
NDArray[float64]
|
vertices of the mesh. |
required |
triangles
|
NDArray[int64]
|
triangles of the mesh (topology). |
required |
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
tuple[NDArray[np.float64], NDArray[np.float64]]: the Laplacian matrix |
NDArray[float64]
|
|
tuple[NDArray[float64], NDArray[float64]]
|
inverse of the sum of the areas of the faces around each vertex, of shape |
sphere_fit_residue ¶
sphere_fit_residue(points: NDArray[float64]) -> float
Get residue from the fit of a sphere from a sample of points in 3D using least squares method.
From https://jekel.me/2015/Least-Squares-Sphere-Fit/ .
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
NDArray[float64]
|
sample of points in 3D |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
reside from least squares method. |
compute_sphere_fit_residues_dict ¶
compute_sphere_fit_residues_dict(graph: Graph) -> dict
Compute a map edge of the graph -> residue from sphere fitting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
Graph
|
Graph constructed from the DcelData. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
map an edge of the graph to a fit residue. |
compute_areas_interfaces ¶
compute_areas_interfaces(mesh: DcelData) -> dict[tuple[int, int], float]
Compute the area of each interface.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
DcelData
|
Mesh |
required |
Returns:
| Type | Description |
|---|---|
dict[tuple[int, int], float]
|
dict[tuple[int, int], float]: map interface defined by two labels -> area. |
compute_triangles_areas ¶
compute_triangles_areas(points: NDArray[float64], triangles: NDArray[int64]) -> NDArray[np.float64]
Compute the area of every triangles in a mesh.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
NDArray[float64]
|
points of a mesh. |
required |
triangles
|
NDArray[float64]
|
triangles (topology) of the mesh. |
required |
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
the areas for each triangle. |