Math Distance calculations Skew lines

Distance between skew lines

Unlike the distance between parallel lines, the distance between skew lines can be traced back to the Hesse normal form.

Given are two skew lines:

$\text{g: } \vec{x} = \vec{p} + r \cdot \vec{m_1}$
$\text{h: } \vec{x} = \vec{q} + s \cdot \vec{m_2}$

We calculate an orthogonal normal vector from the two direction vectors.

$\vec{n}=\vec{m_1}\times\vec{m_2}$

This is normalized (unit normal vector) and inserted into the Hesse normal form together with the two support vectors $\vec{p}$ and $\vec{q}$. The distance $d$ is then obtained.

$d = |(\vec{p} - \vec{a}) \cdot \vec{n_0}|$
i

Method

  1. Calculate normal vector

  2. Form unit normal vector

  3. Insert points in Hesse normal form

Example

Two skew lines are given

$\text{g: } \vec{x} = \begin{pmatrix} 1 \\ 1 \\4 \end{pmatrix} + r \cdot \begin{pmatrix} 1 \\ 1 \\ 0 \end{pmatrix}$

$\text{h: } \vec{x} = \begin{pmatrix} 3 \\ 4 \\ 0 \end{pmatrix} + r \cdot \begin{pmatrix} 1 \\ 5 \\ 2 \end{pmatrix}$

  1. Calculate normal vector

    Variant 1

    Since both direction vectors are perpendicular to the normal vector $\vec{n}=\begin{pmatrix} x \\ y \\ z \end{pmatrix}$, the scalar product must result in zero.

    1. $\begin{pmatrix} x \\ y \\ z \end{pmatrix}\cdot\color{blue}{\begin{pmatrix} 1 \\ 1 \\ 0 \end{pmatrix}} = 0$
    2. $\begin{pmatrix} x \\ y \\ z \end{pmatrix}\cdot\color{blue}{\begin{pmatrix} 1 \\ 5 \\ 2 \end{pmatrix}} = 0$

    The scalar product can now be calculated.

    1. $1x+1y=0$
    2. $1x+5y+2z= 0$

    II.-I.

    $4y+2z=0$

    Choose $z$ freely, e.g. $z=4$

    $4y+8=0\quad|-8$
    $4y=-8\quad|:4$
    $y=-2$

    Calculate $x$ with I. (insert $y$)

    $x+y=0$
    $x-2=0\quad|+2$
    $x=2$

    $\vec{n}=\begin{pmatrix} 2 \\ -2 \\ 4 \end{pmatrix}$

    Variant 2

    In variant 2, only the cross product of the two vectors is formed instead.

    $\vec{n}$ $=\color{blue}{\begin{pmatrix} 1 \\ 1 \\ 0 \end{pmatrix}} \times \color{blue}{\begin{pmatrix} 1 \\ 5 \\ 2 \end{pmatrix}}$ $=\begin{pmatrix} 1\cdot2 - 0\cdot5 \\ 0\cdot1 - 1\cdot2 \\ 1\cdot5 - 1\cdot1 \end{pmatrix}$ $=\begin{pmatrix} 2 \\ -2 \\ 4 \end{pmatrix}$
  2. Unit normal vector

    The normal vector is normalized by dividing by the magnitude of the vector.

    $\vec{n}=\begin{pmatrix} 2 \\ -2 \\ 4 \end{pmatrix}$

    $|\vec{n}|=\sqrt{2^2+(-2)^2+4^2}$ $=\sqrt{24}$

    $\vec{n_0}= \frac{\vec{n}}{|\vec{n}|}$ $=\begin{pmatrix} 2/\sqrt{24} \\ -2/\sqrt{24} \\ 4/\sqrt{24} \end{pmatrix}$

  3. Insert points

    $d=$ $\left|\left(\begin{pmatrix}1 \\ 1 \\4 \end{pmatrix} - \begin{pmatrix} 3 \\ 4 \\ 0\end{pmatrix}\right) \cdot \begin{pmatrix} 2/\sqrt{24} \\ -2/\sqrt{24} \\ 4/\sqrt{24} \end{pmatrix} \right|$ $=\left|\begin{pmatrix} -2 \\ -3 \\ 4 \end{pmatrix} \cdot \begin{pmatrix} 2/\sqrt{24} \\ -2/\sqrt{24} \\ 4/\sqrt{24} \end{pmatrix} \right|$ $\approx3.67$