[Math] Using dot product when finding shortest distance between a line and a point, not working

3dlinear algebravectors

Question goes as follows:
Consider the points on a line; $A(1,3,-1)$ and $B(-1,4,-2)$. Find the point $Q$ on $L$ closest to the point $P(1,1,0)$.

My thinking:
Closest distance from $a$ to $b$ is always a straight line, $90$ degree angle.
Therefore:
$$
Q⋅P=0
$$

$$
L=
\left(\begin{array}{cc}
1\\
3\\
-1\\
\end{array}\right)
+
t
\left(\begin{array}{cc}
-2\\
1\\
-1\\
\end{array}\right)
$$

$$
Q =
\left(\begin{array}{cc}
1-2t\\
3+t\\
-1-t\\
\end{array}\right)
$$

$$
(1-2t)\times(1)+(3+t)\times(1)+(-1-t)\times(0)=0
$$
$$
4-t=0
$$

$$t=4
$$
and
$$
Q=
\left(\begin{array}{cc}
-7\\
7\\
-5\\
\end{array}\right)
$$

But it is wrong, my answer tells me a different story and when I graph it is wrong.

Answer $Q(2,5/2,-1/2)$

Best Answer

Your method is incorrect.

You're supposed to find the point $Q$ such that the vectors $\vec{AQ}$ and $\vec{PQ}$ are perpendicular.

$\vec{AQ} = \vec{OQ} - \vec{OA} = \left(\begin{array}{cc} 2t\\ -t\\ t\\ \end{array}\right)$

$\vec{PQ} = \vec{OQ} - \vec{OP} = \left(\begin{array}{cc} -2t\\ 2+t\\ -1-t\\ \end{array}\right)$

Dot product the two and solve to get: $6t^2 + 3t = 0$.

Reject $t = 0$ (as this makes $Q$ coincident with $A$) to get $t = -\frac 12$, giving you the expected answer.