# How can we represent a self-intersecting surface without analytic expression in computer?

Suppose we have a suface without self-intersection, then we can store it numerically using grid samples from its signed distance funtion. But what for the self-intersecting case, can we still use the SDF tech?

• Yes but you may have to redefine the orientation of the surface in order to get a consistent sign. An even more exotic case is if you have a non-orientable surface, then you cannot get a consistent sign either way. However you can always compute a non-signed distance field. Basically to have a proper sign you need to be able to uniquely determine what is "inside" and "outside", e.g. this is also problematic if you don't have a closed surface/. Aug 23, 2022 at 18:27
• @lightxbulb : And in this case, can we calculate its hessian matrix correctly, with distance function fitted by interpolation on grid samples? There will be sigular points where graidents are zero for self-intersecting surfaces.
– Andy
Aug 28, 2022 at 7:38
• Hessian of what function? And how is this related to the discrete sdf you want? Aug 28, 2022 at 9:26
• @lightxbulb : It's the Hessian of the self-intersecting surface's distance function. If we only have the discrete sdf, can we calculate the Hessian accurately?
– Andy
Aug 28, 2022 at 14:04
• You can compute a discrete analogue of it sure. You can approximate the $x$ derivative: $\partial_x f(i,j) \approx f_{(i+1),j} - f_{i,j}$, and similarly for $y$. For the boundaries either use reflecting, clamped, or toroidal boundary conditions depending on what you want the extension of the function to be beyond its boundaries. Aug 28, 2022 at 14:36