Welcome to our community

Be a part of something great, join today!

Distance between two lines

Petrus

Well-known member
Feb 21, 2013
739
Hello MHB,
This is a problem from my book,
calculate distance between line \(\displaystyle l_1: (x,y,z) = (1,1,3)+t(1,-2,-3)\) and


(hope it work's read \(\displaystyle l_2\) cause I don't know how to write that in latex)
I am stuck when I got \(\displaystyle l_2\) in plane.
I start with \(\displaystyle l_1\)
\(\displaystyle P=(1+t,1-2t,3-3t)\)
what shall I do with \(\displaystyle l_2\)?

Regards,
\(\displaystyle |\pi\rangle\)
 
Last edited:

Klaas van Aarsen

MHB Seeker
Staff member
Mar 5, 2012
8,779
Hello MHB,
This is a problem from my book,
calculate distance between line \(\displaystyle l_1: (x,y,z) = (1,1,3)+t(1,-2,-3)\) and


(hope it work's read \(\displaystyle l_2\) cause I don't know how to write that in latex)
I am stuck when I got \(\displaystyle l_2\) in plane.
I start with \(\displaystyle l_1\)
\(\displaystyle P=(1+t,1-2t,3-3t)\)
what shall I do with \(\displaystyle l_2\)?

Regards,
\(\displaystyle |\pi\rangle\)
Hey I pi rangle! ;)

Which methods do you know to determine the distance between 2 lines?

What you can do for instance with \(\displaystyle l_2\) is find a support vector and a direction vector, so you can define a point Q similar to your point P with 1 parameter.

If you click Reply With Quote you can see how I put your set of equations in $\LaTeX$.
$$l_2:
\left\{
\begin{aligned}
x-\phantom{1}y+3z-1 &= 0 \\
-2x + 3y -6z - 3 &= 0 \\
\end{aligned}
\right.$$
 

Petrus

Well-known member
Feb 21, 2013
739
Hey I pi rangle! ;)

Which methods do you know to determine the distance between 2 lines?

What you can do for instance with \(\displaystyle l_2\) is find a support vector and a direction vector, so you can define a point Q similar to your point P with 1 parameter.

If you click Reply With Quote you can see how I put your set of equations in $\LaTeX$.
$$l_2:
\left\{
\begin{aligned}
x-\phantom{1}y+3z-1 &= 0 \\
-2x + 3y -6z - 3 &= 0 \\
\end{aligned}
\right.$$
Hello I like Serena!
Thanks for showing me the latex code!:)
I know two method one when you do from point to plane which I dont prefer. The method I always use that we is calculate the distance between a vector \(\displaystyle |PQ|\)
this parameter I am unsure with what I shall use.

Regards,
\(\displaystyle |\pi\rangle\)
 

Klaas van Aarsen

MHB Seeker
Staff member
Mar 5, 2012
8,779
Hello I like Serena!
Thanks for showing me the latex code!:)
I know two method one when you do from point to plane which I dont prefer. The method I always use that we is calculate the distance between a vector \(\displaystyle |PQ|\)
this parameter I am unsure with what I shall use.

Regards,
\(\displaystyle |\pi\rangle\)
Can you solve for instance x and y from the set of equations (leaving z as an unknown)?
 

Petrus

Well-known member
Feb 21, 2013
739
Can you solve for instance x and y from the set of equations (leaving z as an unknown)?
Hello I like Serena
I get y=5 and \(\displaystyle x=4-3z\)

Regards,
\(\displaystyle |\pi\rangle\)
 

Klaas van Aarsen

MHB Seeker
Staff member
Mar 5, 2012
8,779
Hello I like Serena
I get y=5 and \(\displaystyle x=4-3z\)

Regards,
\(\displaystyle |\pi\rangle\)
Let's see...

We have $x−y+3z−1=0$.
Substituting your solution, I get:

$$(4-3z)-(5)+3z-1 =0 \\
-2=0 $$

That can't be right!
 

Petrus

Well-known member
Feb 21, 2013
739
Let's see...

We have $x−y+3z−1=0$.
Substituting your solution, I get:

$$(4-3z)-(5)+3z-1 =0 \\
-2=0 $$

That can't be right!
Hello I like Serena
I made some typo sorry!
\(\displaystyle y=5 \) and \(\displaystyle x=6-3z\)

Regards,
\(\displaystyle |\pi\rangle\)
 
Last edited:

Klaas van Aarsen

MHB Seeker
Staff member
Mar 5, 2012
8,779
Hello I like Serena
I made some typo sorry!
\(\displaystyle y=5 \) and \(\displaystyle x=6-3z\)

Regards,
\(\displaystyle |\pi\rangle\)
Good!

Now point $Q$ can be expressed for instance as $(6-3z, 5, z)$.
Or I might also say that $l_2$ is $(6,5,0)+s(-3,0,1)$.

There are a couple of ways to proceed.
Perhaps you already know a way?
 

Petrus

Well-known member
Feb 21, 2013
739
Good!

Now point $Q$ can be expressed for instance as $(6-3z, 5, z)$.
Or I might also say that $l_2$ is $(6,5,0)+s(-3,0,1)$.

There are a couple of ways to proceed.
Perhaps you already know a way?
Hello I like Serena,
Is my method not valid or I am doing something wrong cause I don't get same answer as facit...
We got that
\(\displaystyle PQ=(5-3z-t,4+2t,z-3+3t)\)
We know that \(\displaystyle PQ*(1,-2,-3)=0\) and \(\displaystyle PQ*(-3,0,1)=0\)
then I get this equation
\(\displaystyle 6t+10z=-18\)
\(\displaystyle 14t+6z=6\)
and we get \(\displaystyle t=-\frac{6}{13}\), \(\displaystyle z=\frac{27}{13}\)
that means \(\displaystyle PQ=(-\frac{10}{13},\frac{40}{13},-\frac{30}{13})\)
but this is wrong, and I can't see where..

Regards,
\(\displaystyle |\pi\rangle\)
 

Klaas van Aarsen

MHB Seeker
Staff member
Mar 5, 2012
8,779
We got that
\(\displaystyle PQ=(5-3z-t,4+2t,z-3+3t)\)
We know that \(\displaystyle PQ*(1,-2,-3)=0\) and \(\displaystyle PQ*(-3,0,1)=0\)
Good.

then I get this equation
\(\displaystyle 6t+10z=-18\)
\(\displaystyle 14t+6z=6\)
I don't. How did you get it?
 

Petrus

Well-known member
Feb 21, 2013
739
Good.



I don't. How did you get it?
Hello I like Serena
\(\displaystyle 5-3z-t-2(4+2t)-3(z-3+3t)=0\)
\(\displaystyle -3(5-3z-t)+z-3+3t=0\)

Regards,
\(\displaystyle |\pi\rangle\)
 

Petrus

Well-known member
Feb 21, 2013
739
Hello,
Now I get this equation if I have not made any misscalculation...
\(\displaystyle -6z-14t=-6\)
\(\displaystyle -8z+6t=18\)
\(\displaystyle t=\frac{39}{37}\), \(\displaystyle z=-\frac{54}{37}\)

Regards,
\(\displaystyle |\pi\rangle\)
 

TheBigBadBen

Active member
May 12, 2013
84
This would be my way of continuing:

We begin with the two lines
$$l_1: (x,y,z) = (1,1,3)+t(1,-2,-3)$$
$$l_2: (x,y,z) = (6,5,0)+s(-3,0,1)$$

Now, take any two points on the line, and find the vector going from one to the other. Let's define $P_1=(1,1,3)$ and $P_2=(6,5,0)$. The vector connecting them is then
$$v = P_2 - P_1 = \langle 5,4,-3\rangle$$

Now, you need the component of this vector that is perpendicular to either line. In order to do so, you need some unit vector perpendicular to both $l_1$ and $l_2$. An easy way to find one is to take and normalize the cross product of the line vectors
$$n = \langle 1,-2,-3\rangle \times \langle -3,0,1\rangle
= \langle -2,8,-6 \rangle$$
$$u = n/ \| n \| = \frac{1}{\sqrt{26}} \langle -1,4,-3 \rangle $$

To finish, we have

$$dist = \left| v \cdot u \right| = \left| \frac{1}{\sqrt{26}} ((-1)(5)+(4)(4)+(-3)(-3)) \right|
\\= \frac{20}{\sqrt{26}} \approx 3.92 $$

Is that anything like how you're supposed to do it?
 
Last edited:

Petrus

Well-known member
Feb 21, 2013
739
This would be my way of continuing:

We begin with the two lines
$$l_1: (x,y,z) = (1,1,3)+t(1,-2,-3)$$
$$l_2: (x,y,z) = (6,5,0)+s(-3,0,1)$$

Now, take any two points on the line, and find the vector going from one to the other. Let's define $P_1=(1,1,3)$ and $P_2=(6,5,0)$. The vector connecting them is then
$$v = P_2 - P_1 = \langle 5,4,-3\rangle$$

Now, you need the component of this vector that is perpendicular to either line. In order to do so, you need some unit vector perpendicular to both $l_1$ and $l_2$. An easy way to find one is to take and normalize the cross product of the line vectors
$$n = \langle 1,-2,-3\rangle \times \langle -3,0,1\rangle
= \langle -2,8,-6 \rangle$$
$$u = n/ \| n \| = \frac{1}{\sqrt{26}} \langle -1,4,-3 \rangle $$

To finish, we have

$$dist = \left| v \cdot u \right| = \left| \frac{1}{\sqrt{26}} ((-1)(5)+(4)(4)+(-3)(-3)) \right|
\\= \frac{20}{\sqrt{26}} \approx 3.92 $$

Is that anything like how you're supposed to do it?
Hello,
Your method works fine so should my, I have done some with my method and it works, I don't understand what I am doing wrong

Regards,
\(\displaystyle |\pi\rangle\)
 

TheBigBadBen

Active member
May 12, 2013
84
Hello,
Your method works fine so should my, I have done some with my method and it works, I don't understand what I am doing wrong

Regards,
\(\displaystyle |\pi\rangle\)
Well, I can't tell you what you're doing wrong because I don't really understand your method. Why are you solving for z and t? What information are you looking for, and how does it tie in to finding the distance between lines?
 

Petrus

Well-known member
Feb 21, 2013
739
Well, I can't tell you what you're doing wrong because I don't really understand your method. Why are you solving for z and t? What information are you looking for, and how does it tie in to finding the distance between lines?
Hello TheBigBadBen,
We wanna find z and t so we know PQ, notice that P is on line 1 and Q is on line 2 so with other words Distance between two line is same as |PQ| the length of PQ

Regards,
\(\displaystyle |\pi\rangle\)
 

TheBigBadBen

Active member
May 12, 2013
84
Hello TheBigBadBen,
We wanna find z and t so we know PQ, notice that P is on line 1 and Q is on line 2 so with other words Distance between two line is same as |PQ| the length of PQ

Regards,
\(\displaystyle |\pi\rangle\)
All right, now I see. You're saying that for any point P on line 1 and point Q on line 2, we can write the vector between those two points as

\(\displaystyle PQ=(5-3z-t,4+2t,z-3+3t)\)

Which is correct. Presumably, for the right choice of P and Q, we'd be able to say that the length of that vector is the distance between the two lines. Now, what you need to do (and I now see that this is what you were trying to do) is find such a PQ that is perpendicular to both of the lines. Thus, we need to satisfy
$$ PQ \cdot (1,-2,-3) = 0\\
PQ \cdot (-3,0,1) = 0$$
Which will yield a unique PQ connecting the lines. Finding the length of that should yield the correct answer.

Perfect. Now that I understand, I'll try to see where that went wrong.
 

Klaas van Aarsen

MHB Seeker
Staff member
Mar 5, 2012
8,779
Hello,
Now I get this equation if I have not made any misscalculation...
\(\displaystyle -6z-14t=-6\)
\(\displaystyle -8z+6t=18\)
\(\displaystyle t=\frac{39}{37}\), \(\displaystyle z=-\frac{54}{37}\)

Regards,
\(\displaystyle |\pi\rangle\)
Your equation is still not quite right.

Let's clean it up a bit.

\(\displaystyle \vec{PQ} = \begin{pmatrix}5\\4\\-3\end{pmatrix} + z \begin{pmatrix}-3\\0\\1\end{pmatrix} - t \begin{pmatrix}1\\-2\\-3\end{pmatrix}\)

Since $\vec{PQ} \perp \begin{pmatrix}1\\-2\\-3\end{pmatrix}$, we get:
$$(5-8+9)+z(-3-3)-t(1+4+9)=0$$
And since $\vec{PQ} \perp \begin{pmatrix}-3\\0\\1\end{pmatrix}$, we get:
$$(-15-3)+z(9+1)-t(-3-3)=0$$

Which equations do you get from that?
 

Petrus

Well-known member
Feb 21, 2013
739
Your equation is still not quite right.

Let's clean it up a bit.

\(\displaystyle \vec{PQ} = \begin{pmatrix}5\\4\\-3\end{pmatrix} + z \begin{pmatrix}-3\\0\\1\end{pmatrix} - t \begin{pmatrix}1\\-2\\-3\end{pmatrix}\)

Since $\vec{PQ} \perp \begin{pmatrix}1\\-2\\-3\end{pmatrix}$, we get:
$$(5-8+9)+z(-3-3)-t(1+4+9)=0$$
And since $\vec{PQ} \perp \begin{pmatrix}-3\\0\\1\end{pmatrix}$, we get:
$$(-15-3)+z(9+1)-t(-3-3)=0$$

Which equations do you get from that?
Hello I like Serena,
\(\displaystyle 6z+14t=6\)
\(\displaystyle 10z+9t=18\)
that means \(\displaystyle t=-\frac{24}{43}\) and \(\displaystyle z=\frac{99}{43}\)
that means \(\displaystyle PQ=(-\frac{58}{43},\frac{124}{43},-\frac{102}{43})\)
then we get the distance is and that is not the same as facit..

Regards,
\(\displaystyle |\pi\rangle\)
 

Klaas van Aarsen

MHB Seeker
Staff member
Mar 5, 2012
8,779
Hello I like Serena,
\(\displaystyle 6z+14t=6\)
\(\displaystyle 10z+9t=18\)
that means \(\displaystyle t=-\frac{24}{43}\) and \(\displaystyle z=\frac{99}{43}\)
that means \(\displaystyle PQ=(-\frac{58}{43},\frac{124}{43},-\frac{102}{43})\)
then we get the distance is and that is not the same as facit..

Regards,
\(\displaystyle |\pi\rangle\)
Can you try to simplify $(−15−3)+z(9+1)−t(−3−3)=0$ again?