# SDF collision detection

I was wondering if there are any techniques for calculating the intersection point/s between two or more distance fields.

• Numerical root finders. Analytically you cannot hope for much for anything more complex than very simple objects. Commented Sep 17, 2019 at 9:24
• thanks for the reply @lightxbulb. I was hoping for some kind of smart raymarching algorithm for finding the roots probably using some kind of gradient descent for realtime applications. Commented Sep 17, 2019 at 9:57
• An intersection point of two surfaces described by sdfs $f$ and $g$ is simply $x : f(x) = g(x) = 0$. Provided that $f$ and $g$ are not simplistic, then the roots of that system of equations cannot be found analytically, that is why I mentioned numerical root finding. Under additional constraints you can use gradient or subgradient descent, since then you can try to minimize an energy of the form: $\alpha|f(x)|^p + \beta|g(x)|^q$, which is minimized for $f(x) = g(x) = 0$. If the surfaces do not intersect, it will still be a closest point in some sense. Commented Sep 17, 2019 at 10:05
• I want to ask one more thing. What would you say about precalculating and storing offline a set of points X1n & X2n where f(X1n)=0 g(X2n)=0 respectively and then using that information and I guess some kind of acceleration structure find at least some kind of approximation of the intersection points? Would it work? Could it be done in a better more efficient way? Thanks Commented Sep 17, 2019 at 10:25
• A lot of things may be done. Storing points is not ideal however, since all the points you pick may turn out to not correspond to the intersection. One possibility is to discretize your sdf, and then check all voxels within some threshold, and extract voxels for which both sdfs are close to 0. Another possibility is triangulating the surface and then intersecting the triangles from both surfaces. There are many possible solutions beyond these two examples too. Commented Sep 17, 2019 at 10:35