Skip to content
Related Articles

Related Articles

Distance Formula & Section Formula – Three-dimensional Geometry
  • Last Updated : 19 Jan, 2021
GeeksforGeeks - Summer Carnival Banner

One of the most powerful tools in any engineer or scientist’s toolkit is 3D geometry. 3D geometry comes to picture into model real-world quantities such as velocity, fluid flows, electrical signals, and many other physical quantities. In this article, we are going to discuss two important formulas Distance and Section along with some important examples. One can understand any 3D space in terms of 3 coordinates- x, y, and z. Below is a simple representation of 3D space. 

Representation of Three-dimensional Geometry

Distance Formula and Its Use in 3D Geometry 

The distance formula states the distance between any two points in the XYZ space. 

Formula: 

For two points P1(x1, y1, z1) and P2(x2, y2, z2)



Distance (d) = \sqrt{(x_2-x_1)^2+(y_2-y_1)^2+(z_2-z_1)^2}

This distance formula is used to calculate the distance between two points in any 3D space. When we know the coordinates of the two points in the plane (in form of ordered pair (x, y, z)) we can easily get the distance between two points by substituting in the distance formula.

The Distance Between Two Points: Formulas, and Solved Examples 

Suppose there are two points P(x1, y1, z1) and Q(x2, y2, z2) in the 3D space. To find the distance between them, the formula is,

Distance (d) = \sqrt{(x_2-x_1)^2+(y_2-y_1)^2+(z_2-z_1)^2}

Example 1: Find the distance between the points P(1, –3, 4) and Q (– 4, 1, 2)?

Solution:

Using the formula to calculate the distance between point P and Q, 

Distance (d) = \sqrt{(x_2-x_1)^2+(y_2-y_1)^2+(z_2-z_1)^2}



d = \sqrt{(-4-1)^2+(1+3)^2+(2-4)^2} \\ =\sqrt{25+16+4} \\ =\sqrt{45} \\ =3 \sqrt{5}

Example 2: Show that the points P (–2, 3, 5), Q (1, 2, 3) and R (7, 0, –1) are collinear?

Solution:

We know that points are said to be collinear if they lie on a line.

PQ = \sqrt{(1+2)^2+(2-3)^2+(3-5)^2} = \sqrt{9+1+4} = \sqrt{14}\\ QR = \sqrt{(7-1)^2+(0-2)^2+(-1-3)^2} =  \sqrt{36+4+16} =2 \sqrt{14}\\ PR = \sqrt{(7+2)^2+(0-3)^2+(-1-5)^2} =  \sqrt{81+9+36} =3 \sqrt{14}  

As PQ + QR = PR  

Hence P, Q and R are collinear.

The Distance of Point From a Line: Meaning, Formulas, and Examples 

The distance of a point from a line is the perpendicular distance from the point to the line. Suppose we have to find the distance of a point P(x0, y0, z0) from line l, then the formula is,

Distance (d) = \frac{ |\overline{P0P1}*  \overline{s}| }{ |\overline{s}| }

Where ‘s’ is the directing vector of line l.

Example: Find the distance from point P(-6, 1, 21) to a line \frac{x+4}{3}=\frac{y+5}{1}=\frac{z+1}{1}?

Solution:

L: \frac{(x+4)}3 = \frac{(y+5)}1 = \frac{(z+1)}1 = t \\ P(-6,1,21)\\ P'(3t-4,t-5,t-1) \\ \overline{PP'} = \begin{vmatrix}{3t-4-(-6)} \\ {t-5-1} \\ {t-1-21}\end{vmatrix}  = \begin{vmatrix}{3t+2} \\ {t-6} \\ {t-22}\end{vmatrix} \\ \overline{PP'}* \overline{s}  = 0 \\ \begin{vmatrix}{3t+2} \\ {t-6} \\ {t-22}\end{vmatrix} . \begin{vmatrix}{3} \\ {1} \\ {1}\end{vmatrix} = 0\\ 9t+6+t-6+t-22=0 \\ 11t-22=0 \\ t=2 \\ \overline{PP'} = \begin{vmatrix}{3(2)+2} \\ {(2)-6} \\ {(2)-22}\end{vmatrix} = \begin{vmatrix}{8} \\ {-4} \\ {-20}\end{vmatrix} = 4\begin{vmatrix}{2} \\ {-1} \\ {-5}\end{vmatrix} \\ d = |\overline{PP'}| = 4 \sqrt{4+1+25} = 4 \sqrt{30}

The Distance of a Point from a Plane: Formulas, Equations, and Examples

The distance from a point to a plane is the perpendicular distance from a point on a plane. If Qx + Ry + Sz + T = 0 is a plane equation, then the distance from point P(Px, Py, Pz) to plane can be found using the following formula:

Distance (d) = \frac{ |Q.P_x+R.P_y+S.P_z+T| }{ \sqrt{Q^2+R^2+S^2} }

Example: To find a distance between plane 2x + 4y – 4z – 6 = 0 and point P(0, 3, 6)?

Solution: 

Using the formula: 

Distance (d) = \frac{ |4.1+2.2+(-4).5+-(6)| }{ \sqrt{4^2+2^2+4^2} }\\ =\frac{ |4+4-20-6| }{ \sqrt{16+4+16} }\\ =\frac{ |-18| }{ \sqrt{36} }\\ =\frac{ 18 }{6}\\ =3

The Distance Between Parallel Lines: Formulas and Examples 

The distance between any two parallel lines is the perpendicular distance from any point on one line to the other line. Suppose there are two parallel lines y = mx + c1 and y = mx + c2, then the formula is,

Distance (d) = \frac{|c_2-c_1|}{ \sqrt{1+m^2} }

If the equation of two parallel lines is given as:

ax + by + d1 = 0 and ax + by + d2 = 0, then the formula is,

Distance (d) = \frac{|d_2-d_1|}{ \sqrt{a^2+b^2} }

Where a and b are the coefficients of variables x and y in the line.

Example 1: Find the distance between lines y = 2x + 10 and y = 2x + 12? (Note: Both lines are parallel to each other)

Solution: 

The lines y = 2x + 10 and y = 2x + 12 are in form y = mx + c.

Where c1​ = 10, c2 ​= 12, m = 2 

Using formula, the distance (d) =  \frac{|12-10|}{ \sqrt{1+2^2} } = \frac{2}{\sqrt{5}}

Example 2: Find the distance between two parallel lines 4x + 3y + 6 = 0 and 4x + 3y – 3 = 0?

Solution:

The lines given are 4x + 3y + 6 = 0 and 4x + 3y – 3 = 0. Both lines are in form ax + by + d = 0.

Hence, d1 ​= 6, d2 ​= −3, a = 4, b = 3 

Using formula for this case, distance (d) will be calculated as:

d = \frac{|d2-d1|}{ \sqrt{a^2+b^2} } \\ d = \frac{|-3-6|}{ \sqrt{4^2+3^2} } \\ d = \frac{|-9|}{ \sqrt{16+9} } = \frac{9}{ \sqrt{25} } = \frac{9}{5}

Section Formula: Definition, Vector Formula, Case, and Examples 

Section formula is the concept that can be implemented in 2D and 3D space as well. In three dimension system, we have to choose a coordinate system. Suppose two points P(x1, y1, z1) and Q (x2, y2, z2) are given and let the point R (x, y, z) divide PQ in the given ratio m: n internally. Hence, the coordinates of the point R which divides the line segment joining two points P (x1, y1, z1) and Q (x2, y2, z2) internally in the ratio m: n can be calculated using the formula,

 \left( \frac{mx_2 + nx_1}{m+n},\frac{my_2 + ny_1}{m+n},\frac{mz_2 + nz_1}{m+n}  \right)

If the point R divides PQ externally in the ratio m: n, then its coordinates are obtained by replacing n by – n, and the formula for the same is,

 \left( \frac{mx_2 - nx_1}{m-n},\frac{my_2 - ny_1}{m-n},\frac{mz_2 - nz_1}{m-n}  \right)

Case 1: Coordinates of the mid-point: In case R is the mid-point of PQ, then m : n = 1 : 1 so that

x = \frac{x_1 + x_2}{2}  , y = \frac{y_1 + y_2}{2}   and z = \frac{z_1 + z_2}{2}

These are the coordinates of the midpoint of the segment joining P (x1, y1, z1)and Q (x2, y2, z2). 

Case 2: The coordinates of the point R which divides PQ in the ratio k: 1 are obtained by taking k=\frac{m}{n}   which are as given below,

 \left( \frac{kx_2 + x_1}{k+1},\frac{ky_2 + y_1}{k+1},\frac{kz_2 + z_1}{k+1} \right)

Example 1: Find the coordinates of the point which divides the line segment joining the points (1, –2, 3) and (3, 4, –5) in the ratio 2 : 3 (i) internally, and (ii) externally?

Solution: 

(i) Let P (x, y, z) be the point that divides the line segment joining A(1, – 2, 3)

and B (3, 4, –5) internally in the ratio 2 : 3. Therefore

\frac{2(3)+3(1)}{2+3} = \frac{9}{5} \\ \frac{2(4)+3(-2)}{2+3} = \frac{2}{5} \\ \frac{2(-5)+3(3)}{2+3} = \frac{-1}{5}

Thus, the required point is (\frac{9}{5},\frac{2}{5},\frac{-1}{5})

(ii) Let P (x, y, z) be the point which divides segment joining A (1, –2, 3) and

B (3, 4, –5) externally in the ratio 2 : 3. Then,

\frac{2(3)+(-3)(1)}{2+(-3)} = -3 \\ \frac{2(4)+(-3)(-2)}{2+(-3)} = -14 \\ \frac{2(-5)+(-3)(3)}{2+(-3)} = 19

Therefore, the required point is (–3, –14, 19). 

Example 2: Using section formula, prove that the three points (– 4, 6, 10), (2, 4, 6), and (14, 0, –2) are collinear?

Solution:

Let A (– 4, 6, 10), B (2, 4, 6), and C(14, 0, – 2) be the given points. Let the

point P divides AB in the ratio k: 1. Then coordinates of the point P are

(\frac{2k-4}{k+1},\frac{4k+6}{k+1},\frac{6k+10}{k+1})

Let us examine whether, for some value of k, the point P coincides with point C.

On putting  \frac{2k-4}{k+1}=14\\ k=\frac{-3}{2}  , When k=\frac{-3}{2}  then,

\frac{4k+6}{k+1} =\frac{4 (-\frac{3}{2})+6}{(-\frac{3}{2})+1}=0 \\ and\\ \frac{6k+10}{k+1} =\frac{6 (-\frac{3}{2})+10}{(-\frac{3}{2})+1}=-2 \\

Therefore, C (14, 0, –2) is a point that divides AB externally in the ratio 3: 2 and is

same as P. Hence A, B, C are collinear. 

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :