Intersecting lines in two dimensional space
Consider the equations of two straight lines given by \[ y=m_1x+c_1 \tag{1}\] and \[ y=m_2x+c_2, \tag{2}\] where \(m_1\), \(m_2\), \(c_1\) and \(c_2\) are constants.
In Figure 1 you can play with the slopes and intercepts of the lines. Can you spot a condition that holds on the slopes such that the straight lines do not intersect?
Problems such as the intersection of straight lines can be formulated using linear algebra. In the title of Figure 1 the determinant of a matrix (defined below) is reported for given values of the slopes and intercept. Can you spot a relationship between the value of the matrix determinant and the geometric properties of the lines?
Please note that the app in Figure 1 is approximately 20 MB. If it does not display on your device:
- wait a moment (it is downloading the Python code that will run the app)
- refresh your browser.
If it still does not load, here is a screenshot.
To find the intersection of the lines we can rearrange Equation 1 and Equation 2 to obtain \[ \begin{aligned} m_1x-y&=-c_1, \\ m_2x-y&=-c_2. \end{aligned} \] The equations can be written in matrix-vector form as \[ A \mathbf{x}=\mathbf{b}, \] where \[ A=\begin{pmatrix} m_1 & -1 \\ m_2 & -1\end{pmatrix}, \] and \[ \mathbf{b}=\begin{pmatrix} -c_1 \\ -c_2\end{pmatrix}, \] with \[ \mathbf{x}=\begin{pmatrix} x \\ y\end{pmatrix}. \]
The matrix determinant is defined to be \[ \det{A}=-m_1 +m_2. \]
Hence when the slopes of the lines are equal, the matrix determinant is zero. In this case the lines are parallel and there is either:
- no intersection (the lines have distinct intercepts)
- an infinite family of intersections (the lines also have the same intercept).
Intersecting lines in three dimensional space
We will now explore the intersection of two lines in 3D space.
Consider a line in 3D with direction vector [1,1,1] that passes through the origin. The equation for the line can be written in parametric form as \[ \mathbf{r}_1= \lambda_1 [1,1,1]^T, \quad \lambda_1 \in \Re. \]
Consider a second line defined such that \[ \mathbf{r}_2= \lambda_2 \mathbf{t}+ \mathbf{c}, \quad \lambda_2 \in \Re. \]
In Figure 2 you can play with the direction vector, \(\mathbf{t}\), and the point \(\mathbf{c}\) of the second line.
In the app set \(c=[c_1,c_2,c_3]^T=[0,0,0]^T\). Can you demonstrate that
- when \(t=[t_1,t_2,t_3]^T=[1,-1,0]^T\) that the lines intersect at the origin?
- when \(t=[t_1,t_2,t_3]^T=[1,1,1]^T\) the minimum distance between the lines is reported as nan (not a number)?
To compute the shortest distance between the two lines we can identify the points on each of the lines (parameters \(\lambda^*\) and \(\mu^*\)) that define closest approach. The equations to define \(\lambda^*\) and \(\mu^*\) can be written in matrix-vector form as \[ A \mathbf{x}=\mathbf{b}, \tag{3}\] where \[ A=\begin{pmatrix} \mathbf{s}\cdot\mathbf{s} & -\mathbf{t}\cdot \mathbf{s} \\ \mathbf{t}\cdot \mathbf{s} & -\mathbf{t}\cdot \mathbf{t}\end{pmatrix}, \] and \[ \mathbf{b}=\begin{pmatrix} \mathbf{c}\cdot \mathbf{s} \\ \mathbf{c}\cdot \mathbf{t}\end{pmatrix}, \] with \[ \mathbf{x}=\begin{pmatrix} \lambda^* \\ \mu^*\end{pmatrix}. \] Here \(\mathbf{s}\) represents the direction vector for the first line.
If a solution to Equation 3 can be found then it is straightforward to calculate the shortest distance, \(d\), between the straight lines.
Please note that the app in Figure 2 is approximately 20 MB. If it does not display on your device:
- wait a moment (it is downloading the Python code that will run the app)
- refresh your browser.
If it still does not work, here is a screenshot.
At Dundee, the parametric equations of lines, spheres and planes are studied in the module Maths 1B.
Concepts from geometry and linear algebra are generalised in the modules Maths 2A and Maths 2B.
At Level 3 in the module Differential Geometry geometrical concepts and tools that are essential for understanding classical and modern physics and engineering are further developed.
At Levels 2, 3 and 4 you will learn how to use computer programming to explore and communicate mathematical concepts.
You can find out more about these modules here.