Theory:

Let us recall the distance formula learnt in the previous topics.
Distance formula is used to compute the distance between two definite points.
Distance formula for a line segment parallel to an axis:
Line segment parallel to \(y\)-axis: Let the points be \(A\) and \(B\), and let the coordinates be (\(x_1\), \(y\)) and (\(x_2\), \(y\)) respectively.
 
In both the coordinates, \(y\) is common as both the points lie either on the same axis or parallel to the same axis.
 
In this case, the points lie either on the \(y\)-axis or parallel to \(y\)-axis
 
In such a case, the distance formula will be:
 
\(\text{Distance}\) \(=\) \(|x_1 - x_2|\)
 
 
Line segment parallel to \(x\)-axis: Let the points be \(A\) and \(B\), and let the coordinates be (\(x\), \(y_1\)) and (\(x\), \(y_2\)) respectively.
 
In both the coordinates, \(x\) is common as both the points lie on the same axis or parallel to the same axis.
 
In this case, the points lie either on the \(x\)-axis or parallel to \(x\)-axis.
 
In such a case, the distance formula will be:
 
\(\text{Distance} = |y_1 - y_2|\)
 
 
Let us look at the following example.
 
Find the distance between the points given in the figure below.
 
 
Figure_1.svg
 
 
The coordinates of point \(A\)(\(x_1\), \(y_1\)) is (\(2\), \(3\)).
 
The coordinates of point \(B\)(\(x_2\), \(y_2\)) is (\(2\), \(-2\)).
 
\(x_1 = x_2 = 2\)
 
\(y_1 = 3\)
 
\(y_2 = -2\)
 
Distance between the points \(A\) and \(B\) can be obtained using the distance formula.
 
From the coordinates given above, \(x\)-coordinate is the same across both the points.
 
Therefore, \(\text{Distance} = |y_1 - y_2|\)
 
\(= |2 - (-2)|\)
 
\(= |2 + 2|\)
 
\(= 4\)
 
 
Distance formula if the line segment is not parallel to an axis:
 
Not all line segments are parallel to an axis.
 
Let the points of the line segment be \(A\) and \(B\), and let the co-ordinates be (\(x_1\), \(y_1\)) and (\(x_2\), \(y_2\)) respectively.
 
In that case, the distance formula will be:
 
\(\text{Distance} = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}\)
 
 
Let us look at the following example.
 
Find the distance between the points given in the figure below.
 
 
Figure_2.svg
 
 
The coordinates of point \(A\)(\(x_1\), \(y_1\)) is (\(6\), \(4\)).
 
The coordinates of point \(B\)(\(x_2\), \(y_2\)) is (\(1\), \(-2\)).
 
\(x_1 = 6\)
 
\(x_2 = 1\)
 
\(y_1 = 4\)
 
\(y_2 = -2\)
 
Distance between the points \(A\) and \(B\) can be obtained using the distance formula.
 
\(\text{Distance} = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}\)
 
\(= \sqrt{(1 - 6)^2 + (-2 - 4)^2}\)
 
\(= \sqrt{(-5)^2 + (-6)^2}\)
 
\(= \sqrt{25 + 36}\)
 
\(= \sqrt{61}\)