How do I find the line perpendicular to the intersection of two planes and going through a certain point? The line $r$ has the following equation: 
$ \begin{cases} 
x-y+2=0 \\
2x-z+1=0
\end{cases} $
What's the equation of the line perpendicular to $r$ and going through $P(0,0,-1)$, written in the same form as $r$?
I started solving the system of equations and got $\begin{cases} x=-\dfrac{1}{2} + \dfrac{1}{2} t \\ y = \dfrac{3}{2} + \dfrac{1}{2}t \\
z=t\end{cases}$ but I'm not sure what to do from here.
Thanks in advance.
 A: Now you have a parametric equation $R: \mathbb R\to\mathbb R^3$ for $r$.
Then solve for the $t$ such that $P-R(t)$ is perpendicular to the direction of $r$.
A: The perpendicular will be at the shortest distance between P and r.  Distance (squared) is $(\frac{t-1}{2}-0)^2+(\frac{t+3}{2}-0)^2+(t+1)^2$  Minimum is $t=-1$.  Therefor point on the line is $P_1=(-1,1,-1)$ and the line you want is $P+s(P_1-P)$.
As a check $(P_1-P)\cdot r=0$
A: With $p = (x,y,z)$ given the planes
$$
\Pi_1\to < p-P_1, \vec n_1 > = 0\\
\Pi_2\to < p-P_2, \vec n_2 > = 0
$$
and the point $P_0$ we need a line
$$
L\to p = P_0 + \lambda \vec v
$$
such that $< \vec v, \vec n_1 \times \vec n_2 > =0$ for $\vec v \ne 0$ and also
$$
\Pi_1 \cap L = \Pi_2 \cap L = p^*
$$
or
$$
< p^*-P_1,\vec n_1 > = 0\\
< p^*-P_2,\vec n_2 > = 0\\
<P_0-p^*, \vec n_1\times\vec n_2> = 0
$$
those three conditions give $p^* = (x^*, y^*, z^*)$ the sought point.
NOTE
$<\cdot,\cdot >$ represents the scalar product of two vectors and $\cdot\times\cdot$ represents the vectorial product. Also
$$
\vec n_1 = (1,-1,0)\\
P_1 = (0,2,0)\\
\vec n_2 = (2,0,-1)\\
P_2 = (0,0,1)
$$
A: You can take the plane normal to $r$ and going through $P$ and the plane going through $r$ and through $P$ as two planes defining the line $r_\perp$.
You know that the vector $\mathbf r =(1, 1, 2)$ is parallel to the line $r$, therefore $\mathbf r$ is a normal to the first plane and $\mathbf r \times (P_r - P)$ is a normal to the second plane, where $P_r$ is any point on $r$. Then
$$r_\perp = \cases{ x + y + 2 z + 2 = 0 \\ x + y - z - 1 = 0}.$$
