Projection of a Point on Quadric Surface and Distance of a Point from Quadric Surface Using Normal to the Quadric Surface
Let's consider a Quadric Surface represented by General Quadratic Equations in 3 Variables as follows
\(Ax^2 + By^2 + Cz^2 + Dxy + Exz + Fyz + Gx + Hy + Iz + K=0\) ...(1)
The Projection of any given Point (\(x_0,y_0,z_0\)) on the Quadric Surface given by equation (1) above can be calculated using following steps
Since the Quadric Surface is an Implicit Function of \(x\), \(y\) and \(z\) (i.e. \(F(x,y,z)=0\)), it's Partial Derivatives with respect to Variables \(x\), \(y\) and \(z\) are calculated as
\({\Large \frac{\partial F}{\partial x}} = 2Ax + Dy + Ez + G\) ...(2)
Now, if the Line Connecting the Point (\(x_0,y_0,z_0\)) to any Point (\(x,y,z\)) on the Quadric Surface is Normal to the Quadric Surface, then the Vector given by expression (6) above is same as Vector given by equation (5) Multiplied by Scalar Constant \(t\). That is,
\(t \begin{bmatrix}2Ax + Dy + Ez + G \\ Dx + 2By + Fz + H \\ Ex + Fy + 2Cz + I\end{bmatrix}=\begin{bmatrix}x-x_0 \\ y-y_0 \\ z-z_0\end{bmatrix}\) ...(7)
Equation (7) above can be written in form of a System of Linear Equations in \(x\), \(y\) and \(z\) and represented as the following Matrix Equation
\(\begin{bmatrix}(2At-1) & Dt & Et \\ Dt & (2Bt-1) & Ft \\ Et & Ft & (2Ct-1)\end{bmatrix}\begin{bmatrix}x\\ y \\ z\end{bmatrix}=\begin{bmatrix}-Gt-x_0 \\ -Ht-y_0 \\ -It-z_0\end{bmatrix}\) ...(8)
Find the Value of \(x\), \(y\) and \(z\) by solving the System of Linear Equations given by Matrix Equation (8) above as follows
\(\begin{bmatrix}x\\ y \\ z\end{bmatrix}={\begin{bmatrix}(2At-1) & Dt & Et \\ Dt & (2Bt-1) & Ft \\ Et & Ft & (2Ct-1)\end{bmatrix}}^{-1}\begin{bmatrix}-Gt-x_0 \\ -Ht-y_0 \\ -It-z_0\end{bmatrix}\) ...(9)
The value of \(x\), \(y\) and \(z\) get calculated as
Putting the value of \(x\), \(y\) and \(z\) from equations (10), (11) and (12) above in equation (1) we get a Sextic Polynomial Equation in Variable \(t\).
Solving this Sextic Polynomial Equation in Variable \(t\) can give from 1 to 6 Real Values of \(t\).
Putting these Real Values of Variable \(t\) in equations (10), (11) and (12) above we can get the Points of Projection of the Point (\(x_0,y_0,z_0\)) on the Quadric Surface.
Once all the Points of Projection (\(x,y,z\)) have been calculated, their Distances can be calculated from the Point (\(x_0,y_0,z_0\)). The one with the Minimum Value of Distance is the Distance Between the Point and the Quadric Surface.