# Determine the minimum distance between lines

If anyone got time. Me and my friends appreciate the help We got a problem with the following task:

Determine the minimum distance between lines

Line 1:
$$\begin{eqnarray*} x &=&1+t \\ y &=&2+2t. \end{eqnarray*}$$
Line 2:
$$\begin{eqnarray*} x &=&2-s \\ y &=&1-2s. \end{eqnarray*}$$

Both of these lines intersect the line $x + y = 0$. Determine the respective intersection point and cutting angle. Thanks for taking your time to read this and we hope you could help us out.

1) Distance between the two lines.

The lines are parallel and distinct, so this makes sense. Let us pick the point $P_2=(2,1)$ on line $2$. What you want is the orthogonal projection of $P_2$ on line $1$. There is a formula for that (see other answers), but let's do it as if we didn't know that.

First, you need to determine an equation of the line orthogonal to line $1$ pasing by $P_2$. Since the direction of line $1$ is given by the vector $(1,2)$, the direction of this orthogonal line can be given by $(2,-1)$ (that's a natural way to get an orthogonal vector to $(1,2)$). Then recall this orthogonal line passes through $P_2$ and write the corresponding parameterization.

Now find the intersection of line $1$ and the new orthogonal line you have just determined. Call it $P_1$. The distance between line $1$ and line $2$ is the distance bete ween the points $P_1$ and $P_2$. I assume you know how to compute this given their coordinates.

2)Intersections with $x+y=0$.

Just plug the parameterized coordinates of line $1$ and line $2$ in this equation. Then solve for the parameter.

3) Angle.

A vector perpendicular to the line $x+y=0$ is $w=(1,1)$. A vector perpendicular to line $1$ is $u_1=(2,-1)$. The angle $\theta_1$ between line $1$ and the former is the angle between $w$ and $u_1$. You can use $$\cos\theta_1=\frac{(u_1,w)}{\|u_1\|\|w\|}.$$

You can make a function $d(t)$ which measures the distance from line1 to line2 at a given time. By taking the derivative and setting it equal to 0 you can find a $t$ where the distance is minimal.