The following 3 methods can be used to find the Distance Between a Point and a Line

- Distance
of a point*D*from any line having direction ratio \(\vec{A}\) making a vector \(\vec{B}\) with any point on the line is given by following formula*C*

\(D = \frac{\vert\vec{A}\times\vec{B}\vert}{\vert \vec{A} \vert} \)

The formula given above is applicable for both 2D and 3D lines and it always gives a positive distance value. - For 2D only, distance
of a point*D*from any line having normal vector \(\vec{A}\) making a vector \(\vec{B}\) with any point on the line is given by following formula*C*

\(D = \frac{\vec{A}\cdot\vec{B}}{\vert \vec{A} \vert} \hspace{.5cm} D_{abs} = \frac{|\vec{A}\cdot\vec{B|}}{\vert \vec{A} \vert}\)

The above formula gives a signed distance values (i.e. the distance values can be negative or positive). To find the actual distance absolute value must be taken. - If a 2D line is given by equation \(ax + by + c\) then distance
of this line from a point*D*having coordinates (x*C*_{1},y_{1}) is given by following formula

\(D = \frac{ax_1 + by_1 + c}{\sqrt{a^2 + b^2}} \hspace{.5cm} D_{abs} = \frac{|ax_1 + by_1 + c|}{\sqrt{a^2 + b^2}}\)

The above formula also gives a signed distance values (i.e. the distance values can be negative or positive). To find the actual distance absolute value must be taken.

The distance from the origin is given by the following

\(D = \frac{c}{\sqrt{a^2 + b^2}} \hspace{.5cm} D_{abs} = \frac{|c|}{\sqrt{a^2 + b^2}}\)

The following steps can be used to find distance between Line **A** having direction ratio vector as \(\vec{A}\) passing through a point having position vector \(\vec{C}\) and Line **B** having direction ratio vector as \(\vec{B}\) passing through a point having position vector \(\vec{D}\).

- Find \(\vec{A}\times\vec{B}\).
- If the above
**cross product is zero**then the lines are parallel (or co-incident). The distance between these to lines can be found out by finding the distance of point on one line to the other line by any of the applicable methods given above. In 2D distance between 2 parallel lines can also be found out by finding the absolute value of difference of the distance of the lines from origin. - In 2D, if the above
**cross product is not zero**then the lines are intersecting and hence distance does not have a meaning. - In 3D, if the above
**cross product is not zero**then calculate the unit vector

\(\hat{n} = \frac{\vec{A}\times\vec{B}}{\vert \vec{A}\times\vec{B} \vert}\)

The distancecan be found out by the following formula*D*

\(D = \hat{n} \cdot (\vec{C}-\vec{D}) \)

The above formula gives a signed distance values (i.e. the distance values can be negative or positive).