SDF differentiability (normal and tangent operators)
Normal computation
Contrary to mesh-based geometries,\(\renewcommand{\pB}{\textbf{p}} \renewcommand{\yB}{\textbf{y}} \renewcommand{\nB}{\textbf{n}} \renewcommand{\deltaB}{\mathbf{\delta}}\) signed distance functions (SDFs) possess closed-form differentials. Specifically, if \(\Omega\) is a subset of \(\mathbb{R}^n\) with piecewise smooth boundaries, the SDF is (\(i\)) differentiable almost everywhere, and (\(ii\)) its gradient satisfies \(|\nabla \texttt{sdf}| = 1\). As a result, the unit-normal vector \(\nB(\pB)\) pointing away from the boundary \(\partial \Omega\) can be expressed as \(\nB(\pB):= \nabla \texttt{sdf}(\pB)\). The gradient can be estimated using a finite-difference scheme:
where \({\deltaB}_{i}\) is a vectorized Kronecker delta and \(\varepsilon\) a small increment.
Such finite difference routine is efficiently implemented such that the normal, tangent, and bi-normal vector computations can be called using [N,T,B] = Sdf.gradient(p)
. These gradient vector computations are crucial for contact dynamics with the environment whose topology may be arbitrarily complex.
Example: Normal computation of 2D Sdf
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
Surface projections
The normal vector can also be useful in finding the closest-point projection onto the surface \(\partial \Omega\):
The projection operator is implemented as [P,d] = Sdf.project(p)
, which takes a point cloud \code{p} and returns a point cloud \code{P} that is mapped onto the boundary of the SDF. It also returns the Euclidean distance from the surface. This can be extremely useful in simulations of soft robotic grippers for grasping, or obstacle avoidance for soft manipulators.
Example: Surface projection onto 2D Sdf
1 2 3 4 5 6 7 8 9 10 11 12 |
|