Geometry¶
vertax.geo
Geometric functions over a 2D mesh.
min_image_sq_dist ¶
min_image_sq_dist(p: Array, q: Array, width: float, height: float) -> Array
Squared distance from p to the nearest periodic image of q (2D, PBC).
Under periodic boundary conditions two points can be close through a box face while far
apart in stored coordinates, so the distance is measured to the nearest of the nine images
of q (itself plus translations by +/-width and/or +/-height). This makes the result
independent of which image representative happens to be stored, which is why both the
vertex-to-vertex cost and the periodic T1 swap-repair criterion must use it.
Implemented as one vectorised reduction over a (9, 2) offset array.
Do not rewrite this as jnp.min over a Python list of nine scalars. Under jit
(inside vmap + grad) XLA emitted NaN gradients for that form on real meshes -- 2 of
24 saved dataset meshes -- whereas this form is NaN-free jitted, unjitted, and in the
degenerate case p == q exactly. The equivalent (min_k sqrt(u_k))**2 spelling is
defective: its AD path is 0/0 -> NaN when p == q.
get_length ¶
get_length(he: Array, vertTable: Array, heTable: Array, _faceTable: Array, width: float, height: float) -> Array
Get the lengths of given half-edges.
get_length_with_offset ¶
get_length_with_offset(he: Array, vertTable: Array, heTable: Array, _faceTable: Array, width: float, height: float) -> Array
Get the length and associated offsets for given half-edges.
get_perimeter ¶
get_perimeter(face: Array, vertTable: Array, heTable: Array, faceTable: Array, width: float, height: float, max_iter: int) -> Array
Get the perimeters of given faces.
get_area ¶
get_area(face: Array, vertTable: Array, heTable: Array, faceTable: Array, width: float, height: float, max_iter: int) -> Array
Get area of given faces (using shoelace formula).
update_pbc ¶
update_pbc(vertTable: Array, heTable: Array, faceTable: Array, width: float, height: float) -> tuple[Array, Array, Array]
Updating vertices positions and offsets for periodic boundary conditions.
select_verts_hes_faces_inside ¶
select_verts_hes_faces_inside(vertTable: Array, heTable: Array, faceTable: Array, x_min: float, x_max: float, y_min: float, y_max: float) -> tuple[Array, Array, Array]
Get a selection of all vertices, edges and faces for faces that lie totally inside the bounds.
get_edge_length ¶
get_edge_length(he: Array, vertTable: Array, heTable: Array) -> Array
For a bounded mesh, get the length of straight edges, and 0 for boundary edges.
get_chord_length ¶
get_chord_length(he: Array, vertTable: Array, heTable: Array) -> Array
For a bounded mesh, get the chord lengths of boundary edges, and 0 for non-boundary edges.
get_surface_length ¶
get_surface_length(he: Array, vertTable: Array, angTable: Array, heTable: Array) -> Array
For a bounded mesh, get the lengths of boundary edges, and 0 for non-boundary edges.
get_area_bounded ¶
get_area_bounded(face: Array, vertTable: Array, angTable: Array, heTable: Array, faceTable: Array) -> Array
Get the areas of given faces.
get_any_length ¶
get_any_length(he: Array, vertTable: Array, angTable: Array, heTable: Array) -> Array
Get bounded length for both surface and inside edges.
get_perimeter_bounded ¶
get_perimeter_bounded(face: Array, vertTable: Array, angTable: Array, heTable: Array, faceTable: Array) -> Array
Get the perimeters of given faces.
get_cluster_moments_bounded ¶
get_cluster_moments_bounded(vertTable: Array, angTable: Array, heTable: Array) -> tuple[Array, Array, Array]
Area, centroid and central second-moment matrix of the whole region covered by a bounded mesh.
The region is the union of the cells, each with its circular caps on the free interface, exactly
the region whose cell areas get_area_bounded returns. Its moments are computed by Green's
theorem: every half-edge of a cell contributes the moments of the triangle it spans with the
origin, and every free interface adds the moments of its circular cap, which always lies outside
its cell. Faces are traversed counterclockwise (BoundedMesh builds them so and T1 transitions
keep it), so the triangles are signed by the traversal and each cap lies to the right of its
directed chord. The orientation is not read from the sign of a cell's chord polygon, which turns
over in a crescent (a cell whose interior vertices have crossed the chord of its arc) while the
cell and its cap keep their side.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vertTable
|
Array
|
vertex positions as stored in |
required |
angTable
|
Array
|
one arc half-angle per edge, as stored in |
required |
heTable
|
Array
|
the half-edge table, as stored in |
required |
Returns:
| Type | Description |
|---|---|
tuple[Array, Array, Array]
|
|