Finding the closest distance between a point and a surface Assuming that I am given a matrix (A) and a vector (b) which represents a surface, say

\begin{bmatrix}2&amp;0&amp;1\\0&amp;1&amp;0\\1&amp;0&amp;2\end{bmatrix} and \begin{bmatrix}4\\0\\2\end{bmatrix}

and the equation representing the surface as:
$r^TAr+b^Tr=1$

If I am asked to find the closest distance between point "a" and the surface, represented by a position vector of

\begin{bmatrix}-1\\0\\0\end{bmatrix}

What am I supposed to do?



Below is what I've attempted:

Using this as an example, I tried to rewrite the equation representing the surface into quadratic form, in this case:

$x^T Ax=3$

where $r=x+a$ (note: $a$ is the point where I am trying to find it's distance from the surface).

I'm thinking about rotating the axis, however I am stuck here (my teacher told me to try not consider a rotation matrix).
My first idea for what to do: First, rewrite your equation $$r^TAr + b^Tr = 1 $$ into $$(r-c)^TA(r-c) = d$$
(You can find a suitable $c$ by multiplying out $(r-c)^TA(r-c)$, rewriting $r^TAc=c^TAr$ and solving $b^T = -2c^TA$. Then $d$ must be $1+c^TAc$ -- though I haven't triple-checked my reasoning for sign errors; caveat lector).

$A$ is real symmetric and therefore orthogonally diagonalizable; it is easy to see that its eigenvalues are $1,1,3$ and therefore your surface is an oblate spheroid centered on $c$.

Now the natural thing to do would be to transform $a-c$ by the orthogonal diagonalizing matrix, so you end up with $a-c$ in a coordinate system where $A=\operatorname{diag}(1,1,3)$. Then by symmetry the shortest line betwen $a$ and the spheroid would be in the plane that contains the transformed point and the $z$-axis, and we've reduced the problem to finding the shortest distance between a point and an ellipse. That seems to have no nice closed-form solution, but at least it is now easy to parameterize the ellipse and find a minimum numerically by setting the derivative of the squared distance to $0$.

However, this works because the diagonalizing matrix for $A$ can be chosen to be orthogonal -- that is, a rotation matrix -- which sounds like what your teacher is asking you not to do.



It is possible that you're supposed to use Lagrange multipliers instead.
Closest distance between a plane and a line goes like this:
If plane is ax+by+cz=d where a,b,c,d are constants and the point is (h,k,l)
Then shortest distance is
(ha+bk+cl-d)/root(a^2+b^2+c^2)