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

  • $\begingroup$ If you want it numerically anyway, why not just do this: let $p=(x_p,y_p,z_p)$; first find $x,y,z$ with $x_p-x=\lambda f_x,y_p-y=\lambda f_y,z_p-z=\lambda f_z$; then $f(x,y,z)=0$ will give you a fourth degree equation for $\lambda$. Pick the root with smallest value of $(x_p-x)^2+(y_p-y)^2+(z_p-z)^2$. $\endgroup$ – მამუკა ჯიბლაძე Jul 4 '18 at 21:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.