Find line orthogonal to another line passing through point p in R³ So in R³, given a line $G$ in parameter form and a point Q, how do I compute the line passing through Q that is orthogonal to $G$?
In order for two vectors to be orthogonal, the dot product has to be zero. Also, for a point to be located on a line, inserting the point into the line equation must result in equality, right? Not quite sure how to use this for the task.
A hint to get me on the right track would suffice
 A: Let $G: \mathbf{a}+\alpha \mathbf{b}$ and let $\mathbf{q}$ be the vector from the origin to the point $Q$. Then determine the point on $G$ which is closest to $Q$ by minimizing the distance:
$$d=(\mathbf{q}-\mathbf{a}-\alpha\mathbf{b})^T(\mathbf{q}-\mathbf{a}-\alpha\mathbf{b})$$
This gives you a quadratic equation in $\alpha$ which can be easily minimized by taking the derivative w.r.t. $\alpha$ and setting it to zero. The result is
$$\alpha_0=\frac{ \mathbf{b}^T(\mathbf{q}-\mathbf{a})}{ \mathbf{b}^T\mathbf{b} }$$
So we have a point on $G$ and on the desired line $H$:
$$\mathbf{c}=\mathbf{a}+\alpha_0\mathbf{b}$$
Then the line $H$ can be parametrized by
$$H: \mathbf{c}+\beta(\mathbf{q}-\mathbf{c})$$
A: For $P \in G$, compute $\vec{PQ}$ (which depends on the parameter $\lambda$). Then $\vec{PQ} \cdot \vec{G}=0$ (where $\vec{G}$ is the direction of $G$) is a linear equation in $\lambda$.
If $G=\{\lambda (g_x, g_y, g_z) + (p_x, p_y, p_z)\}$ and $Q=(q_x, q_y,q_z)$, then $\vec PQ=(\lambda g_x + p_x -q_x, \lambda g_y + p_y -q_y, \lambda g_z+ p_z -q_z)$ and $\vec PQ \perp G$ iff $g_x(\lambda g_x + p_x -q_x)+g_y(\lambda g_y + p_y -q_y+ g_z(\lambda g_z+ p_z -q_z)$.
That is, iff $\lambda (g_x^2 + g_y^2 + g_z^2) = g_x(p_x-q_x)+g_y(p_y-q_y)+g_z(p_z-q_z)$.
