meshing.edge_detection.edge_hermite_data

meshing.edge_detection.edge_hermite_data(
    sdf,
    grid,
    edges,
    *,
    level=0.0,
    bisection_iterations=16,
    newton_steps=1,
)

Locate the surface crossing on every edge and evaluate its gradient.

The function is JAX-traceable end to end. Calling it under jax.grad or jax.jit with a field that closes over traced design parameters yields exact implicit derivatives of the crossing positions, parameters, and gradients. The edge set itself stays frozen; re-detect edges after parameter changes large enough to alter the crossing topology.

If a frozen edge no longer brackets a root under new parameter values, bisection collapses toward an endpoint and the Newton correction steps toward the nearest root along the edge line, possibly outside [0, 1]. A proposed Newton step is kept only when it does not worsen the field residual, so tangency-degenerate edges — where the slope is float noise and the linearization is meaningless — fall back to the bisection point instead of jumping. This keeps positions continuous across small parameter perturbations, which is what an optimization loop needs between re-extractions.

Parameters

Name Type Description Default
sdf Callable[[Array], Array] JAX-traceable scalar field (point[3]) -> scalar. required
grid GridSpec The grid the edges were detected on. required
edges CrossingEdges Crossing edges from :func:find_crossing_edges. required
level float Isovalue to extract. 0.0
bisection_iterations int Sign-based bracket halvings; run on stop_gradient values, so they add accuracy but no gradient path. 16
newton_steps int Differentiable Newton corrections applied after bisection. Must be at least 1 for the crossing parameter t (and hence points and the positional part of gradients) to carry parameter gradients; with 0 they are constant, though values and gradients still differentiate as field evaluations at fixed points. 1

Returns

Name Type Description
HermiteData Hermite data for every edge, in the order of edges.