In a three-dimensional space there exists a point $A$ and it's position vector $a$ is expressed as
$$a=\overrightarrow{OA}=\begin{bmatrix} a_{1} \\a_{2} \\ a_{3} \end{bmatrix}$$
There is also a straight line $l$ which is passing through point $A$ and has a direction vector $v$
$$v=\begin{bmatrix} v_{1} \\v_{2} \\ v_{3} \end{bmatrix}(\neq 0)$$
In the same space there is also exists another point (point $P$) which has a position vector $p$
$$p=\overrightarrow{OP}=\begin{bmatrix} p_{1} \\p_{2} \\ p_{3} \end{bmatrix}$$
Let's also assume that point $Q$ is a point on $l$ and is the closest point to $P$. Point $Q$ has a position vector $q$
$$q=\overrightarrow{OQ}=\begin{bmatrix} q_{1} \\q_{2} \\ q_{3} \end{bmatrix}$$
I am asked to rewrite $q$ to the form $q=Lp+b$, where matrix $L$ and vector $b$ are only determined by $l$.
I could only find that the equation for the straight line $l$ is
$$x=a_{1}+v_{1}t$$ $$y=a_{2}+v_{2}t$$ $$z=a_{3}+v_{3}t$$
and got stuck. Any suggestions?
This is a direct translation of the original problem. If something does not sound right, let me know.
Let's get some intuition for the problem by solving it in the simpler case of when $a = 0$. In this case, $\ell$ goes through the origin, and $q$ must be of the form $q = vt$ for some yet unknown $t$. This $t$ is chosen such that the length $\|q-p\|$ is minimized. Equivalently, we can minimize $\|q-p\|^2$, which simplifies as such: $$ \begin{align} \|q-p\|^2 & = \|vt-p\|^2 = (vt-p)\cdot(vt-p) \\ & = \|v\|^2t^2 - 2(v\cdot p)t + \|p\|^2. \end{align} $$ This is a quadratic in $t$, and its minimum occurs at its vertex, at $$ t_{min} = -\frac{-2(v\cdot p)}{2\|v\|^2} = \frac{(v\cdot p)}{\|v\|^2}. $$ So, $$ q = vt_{min} = \frac{(p\cdot v)}{\|v\|^2}v. $$ In other words, when $a = 0$, $q$ is the projection of $p$ onto the span of $v$. Projection is a type of linear transformation, so in this case we'd expect that writing $q = Lp + b$ should have $b = 0$ and $L$ being the corresponding projection matrix.
A commonly known fact about matrices is that the columns are the coordinates of the images of the underlying basis vectors, in our case $e_1 = (1,0,0)$, etc. Plugging $e_1, e_2, e_3$ into our formula for $q$ therefore reveals that $$ L = \frac{1}{\|v\|^2}\begin{bmatrix} v_1^2 & v_1v_2 & v_1v_3 \\ v_1v_2 & v_2^2 & v_2v_3\\ v_1v_3 & v_2v_3 & v_3^2 \end{bmatrix}. $$ We verify that indeed, $Lp = q$ in this case: $$ \begin{align} Lp & = \frac{1}{\|v\|^2}\begin{bmatrix} v_1^2 & v_1v_2 & v_1v_3 \\ v_1v_2 & v_2^2 & v_2v_3\\ v_1v_3 & v_2v_3 & v_3^2 \end{bmatrix} \begin{bmatrix} p_1 \\ p_2 \\ p_3 \end{bmatrix} = \frac{1}{\|v\|^2}\begin{bmatrix} (p_1v_1 + p_2v_2 p_3v_3)v_1 \\ (p_1v_1 + p_2v_2 p_3v_3)v_2 \\ (p_1v_1 + p_2v_2 p_3v_3)v_3 \end{bmatrix} = \frac{(p\cdot v)}{\|v\|^2} \begin{bmatrix} v_1 \\ v_2 \\ v_3 \end{bmatrix} \\ & = \frac{(p\cdot v)}{\|v\|^2}v = q. \end{align} $$
How about the case when $a$ is nonzero? Well, by translating the whole system by $-a$, this is equivalent to finding the "$q$" associated to $p-a$ in the "$a=0$" case, and then translating back by $a$. Therefore, in general, $$ q = a + L(p-a) = Lp + (a-La) = a + \frac{(p-a)\cdot v}{\|v\|^2}v. $$ That is, your final answer is $$ \boxed{L = \frac{1}{\|v\|^2}\begin{bmatrix} v_1^2 & v_1v_2 & v_1v_3 \\ v_1v_2 & v_2^2 & v_2v_3\\ v_1v_3 & v_2v_3 & v_3^2 \end{bmatrix} = \frac1{\|v\|^2}vv^T, \ \ b = a - La = a - \frac{(a\cdot v)}{\|v\|^2}v.} $$