Point-line Distance
   HOME

TheInfoList



OR:

The distance (or perpendicular distance) from a point to a line is the shortest
distance Distance is a numerical or occasionally qualitative measurement of how far apart objects, points, people, or ideas are. In physics or everyday usage, distance may refer to a physical length or an estimation based on other criteria (e.g. "two co ...
from a fixed point to any point on a fixed infinite line in
Euclidean geometry Euclidean geometry is a mathematical system attributed to ancient Greek mathematics, Greek mathematician Euclid, which he described in his textbook on geometry, ''Euclid's Elements, Elements''. Euclid's approach consists in assuming a small set ...
. It is the length of the
line segment In geometry, a line segment is a part of a line (mathematics), straight line that is bounded by two distinct endpoints (its extreme points), and contains every Point (geometry), point on the line that is between its endpoints. It is a special c ...
which joins the point to the line and is
perpendicular In geometry, two geometric objects are perpendicular if they intersect at right angles, i.e. at an angle of 90 degrees or π/2 radians. The condition of perpendicularity may be represented graphically using the '' perpendicular symbol'', ⟠...
to the line. The formula for calculating it can be derived and expressed in several ways. Knowing the shortest distance from a point to a line can be useful in various situations—for example, finding the shortest distance to reach a road, quantifying the scatter on a graph, etc. In
Deming regression In statistics, Deming regression, named after W. Edwards Deming, is an errors-in-variables model that tries to find the line of best fit for a two-dimensional data set. It differs from the simple linear regression in that it accounts for errors ...
, a type of linear curve fitting, if the dependent and independent variables have equal variance this results in
orthogonal regression In statistics, Deming regression, named after W. Edwards Deming, is an errors-in-variables model that tries to find the line of best fit for a two-dimensional data set. It differs from the simple linear regression in that it accounts for errors ...
in which the degree of imperfection of the fit is measured for each data point as the perpendicular distance of the point from the regression line.


Cartesian coordinates


Line defined by an equation

In the case of a line in the plane given by the equation where ''a'', ''b'' and ''c'' are
real Real may refer to: Currencies * Argentine real * Brazilian real (R$) * Central American Republic real * Mexican real * Portuguese real * Spanish real * Spanish colonial real Nature and science * Reality, the state of things as they exist, rathe ...
constants with ''a'' and ''b'' not both zero, the distance from the line to a point (''x''0,''y''0) is :\operatorname(ax+by+c=0, (x_0, y_0)) = \frac. The point on this line which is closest to (''x''0,''y''0) has coordinates: :x = \frac \text y = \frac. Horizontal and vertical lines In the general equation of a line, ''ax'' + ''by'' + ''c'' = 0, ''a'' and ''b'' cannot both be zero unless ''c'' is also zero, in which case the equation does not define a line. If ''a'' = 0 and ''b''  0, the line is horizontal and has equation ''y'' = -''c''/''b''. The distance from (''x''0, ''y''0) to this line is measured along a vertical line segment of length , ''y''0 - (-''c''/''b''), = , ''by''0 + ''c'', / , ''b'', in accordance with the formula. Similarly, for vertical lines (''b'' = 0) the distance between the same point and the line is , ''ax''0 + ''c'', / , ''a'', , as measured along a horizontal line segment.


Line defined by two points

If the line passes through two points ''P''1=(''x''1,''y''1) and ''P''2=(''x2'',''y2'') then the distance of (x0,y0) from the line is: :\operatorname(P_1, P_2, (x_0, y_0)) = \frac. The denominator of this expression is the distance between ''P1'' and ''P2''. The numerator is twice the area of the triangle with its vertices at the three points, (x0,y0), ''P1'' and ''P2''. See: . The expression is equivalent to h=\frac, which can be obtained by rearranging the standard formula for the area of a triangle: A=\frac bh, where ''b'' is the length of a side, and ''h'' is the perpendicular height from the opposite vertex.


Line defined by point and angle

If the line passes through the point with angle , then the distance of some point to the line is :\operatorname(P, \theta, (x_0, y_0)) = , \cos(\theta)(P_y-y_0) -\sin(\theta)(P_x-x_0),


Proofs


An algebraic proof

This proof is valid only if the line is neither vertical nor horizontal, that is, we assume that neither ''a'' nor ''b'' in the equation of the line is zero. The line with equation ''ax'' + ''by'' + ''c'' = 0 has slope −''a''/''b'', so any line perpendicular to it will have slope ''b''/''a'' (the negative reciprocal). Let (''m'', ''n'') be the point of intersection of the line ''ax'' + ''by'' + ''c'' = 0 and the line perpendicular to it which passes through the point (''x''0, ''y''0). The line through these two points is perpendicular to the original line, so :\frac=\frac. Thus, a(y_0 -n) - b(x_0 - m) = 0, and by squaring this equation we obtain: :a^2(y_0 - n)^2 + b^2(x_0 - m)^2 = 2ab(y_0 - n)(x_0 - m). Now consider, : (a(x_0 - m) + b(y_0 - n))^2 = a^2(x_0 - m)^2 + 2ab(y_0 -n)(x_0 - m) + b^2(y_0 - n)^2 = (a^2 + b^2)((x_0 - m)^2 + (y_0 - n)^2) using the above squared equation. But we also have, : (a(x_0 - m) + b(y_0 - n))^2 = (ax_0 + by_0 - am -bn )^2 = (ax_0 + by_0 + c)^2 since (''m'', ''n'') is on ''ax'' + ''by'' + ''c'' = 0. Thus, :(a^2 + b^2)((x_0 - m)^2 + (y_0 - n)^2) = (ax_0 + by_0 + c)^2 and we obtain the length of the line segment determined by these two points, :d=\sqrt= \frac.


A geometric proof

This proof is valid only if the line is not horizontal or vertical. Drop a perpendicular from the point ''P'' with coordinates (''x''0, ''y''0) to the line with equation ''Ax'' + ''By'' + ''C'' = 0. Label the foot of the perpendicular ''R''. Draw the vertical line through ''P'' and label its intersection with the given line ''S''. At any point ''T'' on the line, draw a right triangle ''TVU'' whose sides are horizontal and vertical line segments with hypotenuse ''TU'' on the given line and horizontal side of length , ''B'', (see diagram). The vertical side of ∆''TVU'' will have length , ''A'', since the line has slope -''A''/''B''. ∆''PRS'' and ∆''TVU'' are
similar triangles In Euclidean geometry, two objects are similar if they have the same shape, or if one has the same shape as the mirror image of the other. More precisely, one can be obtained from the other by uniformly scaling (enlarging or reducing), possibly ...
, since they are both right triangles and ∠''PSR'' ≅ ∠''TUV'' since they are corresponding angles of a transversal to the parallel lines ''PS'' and ''UV'' (both are vertical lines). Corresponding sides of these triangles are in the same ratio, so: :\frac = \frac. If point ''S'' has coordinates (''x''0,''m'') then , ''PS'', = , ''y''0 - ''m'', and the distance from ''P'' to the line is: : , \overline , = \frac. Since ''S'' is on the line, we can find the value of m, :m = \frac, and finally obtain: : , \overline, = \frac. A variation of this proof is to place V at P and compute the area of the triangle ∆''UVT'' two ways to obtain that D, \overline, = , \overline, , \overline, where D is the altitude of ∆''UVT'' drawn to the hypoteneuse of ∆''UVT'' from ''P''. The distance formula can then used to express , \overline, , , \overline, , and , \overline, in terms of the coordinates of P and the coefficients of the equation of the line to get the indicated formula.


A vector projection proof

Let ''P'' be the point with coordinates (''x''0, ''y''0) and let the given line have equation ''ax'' + ''by'' + ''c'' = 0. Also, let ''Q'' = (''x''1, ''y''1) be any point on this line and n the vector (''a'', ''b'') starting at point ''Q''. The vector n is perpendicular to the line, and the distance ''d'' from point ''P'' to the line is equal to the length of the orthogonal projection of \overrightarrow on n. The length of this projection is given by: :d = \frac. Now, : \overrightarrow = (x_0 - x_1, y_0 - y_1), so \overrightarrow \cdot \mathbf = a(x_0 - x_1) + b(y_0 - y_1) and \, \mathbf \, = \sqrt, thus : d = \frac. Since ''Q'' is a point on the line, c = -ax_1 - by_1, and so, : d = \frac.


Another formula

It is possible to produce another expression to find the shortest distance of a point to a line. This derivation also requires that the line is not vertical or horizontal. The point P is given with coordinates (x_0, y_0). The equation of a line is given by y=mx+k. The equation of the normal of that line which passes through the point P is given y=\frac+y_0. The point at which these two lines intersect is the closest point on the original line to the point P. Hence: :mx+k=\frac+y_0. We can solve this equation for ''x'', :x=\frac. The ''y'' coordinate of the point of intersection can be found by substituting this value of ''x'' into the equation of the original line, :y=m\frac+k. Using the equation for finding the distance between 2 points, d=\sqrt, we can deduce that the formula to find the shortest distance between a line and a point is the following: :d=\sqrt = \frac\sqrt . Recalling that ''m'' = −''a''/''b'' and ''k'' = − ''c''/''b'' for the line with equation ''ax'' + ''by'' + c = 0, a little algebraic simplification reduces this to the standard expression.


Vector formulation

The equation of a line can be given in
vector Vector most often refers to: * Euclidean vector, a quantity with a magnitude and a direction * Disease vector, an agent that carries and transmits an infectious pathogen into another living organism Vector may also refer to: Mathematics a ...
form: : \mathbf = \mathbf + t\mathbf Here is the position of a point on the line, and is a
unit vector In mathematics, a unit vector in a normed vector space is a Vector (mathematics and physics), vector (often a vector (geometry), spatial vector) of Norm (mathematics), length 1. A unit vector is often denoted by a lowercase letter with a circumfle ...
in the direction of the line. Then as scalar ''t'' varies, gives the
locus Locus (plural loci) is Latin for "place". It may refer to: Mathematics and science * Locus (mathematics), the set of points satisfying a particular condition, often forming a curve * Root locus analysis, a diagram visualizing the position of r ...
of the line. The distance of an arbitrary point to this line is given by : \operatorname(\mathbf = \mathbf + t\mathbf, \mathbf) = \, (\mathbf-\mathbf) - ((\mathbf-\mathbf) \cdot \mathbf)\mathbf \, . This formula can be derived as follows: \mathbf-\mathbf is a vector from to the point on the line. Then (\mathbf - \mathbf) \cdot \mathbf is the projected length onto the line and so :((\mathbf - \mathbf) \cdot \mathbf)\mathbf is a vector that is the
projection Projection or projections may refer to: Physics * Projection (physics), the action/process of light, heat, or sound reflecting from a surface to another in a different direction * The display of images by a projector Optics, graphics, and carto ...
of \mathbf-\mathbf onto the line. Thus :(\mathbf-\mathbf) - ((\mathbf-\mathbf) \cdot \mathbf)\mathbf is the component of \mathbf-\mathbf perpendicular to the line. The distance from the point to the line is then just the
norm Norm, the Norm or NORM may refer to: In academic disciplines * Normativity, phenomenon of designating things as good or bad * Norm (geology), an estimate of the idealised mineral content of a rock * Norm (philosophy), a standard in normative e ...
of that vector. This more general formula is not restricted to two dimensions.


Another vector formulation

If the line (''l'' ) goes through point A and has a
direction vector In geometry, direction, also known as spatial direction or vector direction, is the common characteristic of all rays which coincide when translated to share a common endpoint; equivalently, it is the common characteristic of vectors (such as ...
\vec u, the distance between point P and line (''l'') is : d(\mathrm, (l))= \frac where \overrightarrow \times\vec u is the
cross product In mathematics, the cross product or vector product (occasionally directed area product, to emphasize its geometric significance) is a binary operation on two vectors in a three-dimensional oriented Euclidean vector space (named here E), and ...
of the vectors \overrightarrow and \vec u and where \, \vec u\, is the vector norm of \vec u. \overrightarrow=P-A Note that cross products only exist in dimensions 3 and 7 and trivially in dimensions 0 and 1 (where the cross product is constant 0).


See also

*
Hesse normal form In analytic geometry, the Hesse normal form (named after Otto Hesse) is an equation used to describe a line in the Euclidean plane \mathbb^2, a plane in Euclidean space \mathbb^3, or a hyperplane in higher dimensions.John Vince: ''Geometry for C ...
*
Line–line intersection In Euclidean geometry, the intersection of a line and a line can be the empty set, a point (geometry), point, or another Line (geometry), line. Distinguishing these cases and finding the Intersection (Euclidean geometry), intersection have uses, ...
*
Distance between two parallel lines The distance Distance is a numerical or occasionally qualitative measurement of how far apart objects, points, people, or ideas are. In physics or everyday usage, distance may refer to a physical length or an estimation based on other criter ...
*
Distance from a point to a plane In Euclidean space, the distance from a point to a plane is the distance between a given point and its orthogonal projection on the plane, the perpendicular distance to the nearest point on the plane. It can be found starting with a change of vari ...
*


Notes


References

* * * *


Further reading

*{{citation, title=Encyclopedia of Distances, first1=Michel Marie, last1=Deza, author1-link=Michel Deza, first2=Elena, last2=Deza, edition=2nd, publisher=Springer, year=2013, isbn=9783642309588, page=86, url=https://books.google.com/books?id=QxX2CX5OVMsC&pg=PA86 Euclidean geometry Vectors (mathematics and physics) Distance