I asked a similar question on math.stackexchange, but the answer wasn't quite ideal for my application. Apparently analytic solutions are surprisingly rare for general quadric distances.
Given a surface $S$ generated by quadric equation
$$f(x,y,z) = Ax^2 + By^2 + Cz^2 + Dxy + Exz + Fyz + Gx + Hy + Iz + J = 0$$
and a point $p$ not on that surface, is there an analytic solution for the minimum Euclidean distance between $p$ and $S$ ? Previous solutions I've seen try points on the surface and optimize from there, but after implementing code for that method, I found it takes many hours to converge.
Thanks! Also, please correct my tags; I feel woefully inept at maths at the moment