Distance from a point to a line: Difference between revisions

Content deleted Content added
Adding local short description: "Geometry problem", overriding Wikidata description "geometry"
Citation bot (talk | contribs)
Altered isbn. Add: jstor, issue. Upgrade ISBN10 to 13. | Use this bot. Report bugs. | #UCB_CommandLine
 
(9 intermediate revisions by 6 users not shown)
Line 15:
'''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''&nbsp;=&nbsp;0 and ''b''&nbsp;{{math|≠}}&nbsp;0, the line is horizontal and has equation ''y'' = -''c''/''b''. The distance from (''x''<sub>0</sub>, ''y''<sub>0</sub>) to this line is measured along a vertical line segment of length |''y''<sub>0</sub> - (-''c''/''b'')| = |''by''<sub>0</sub> + ''c''| / |''b''| in accordance with the formula. Similarly, for vertical lines (''b'' = 0) the distance between the same point and the line is |''ax''<sub>0</sub> + ''c''| / |''a''|, as measured along a horizontal line segment.
 
===Line defined by two points===
Line 22:
 
The denominator of this expression is the distance between ''P<sub>1</sub>'' and ''P<sub>2</sub>''. The numerator is twice the area of the triangle with its vertices at the three points, (x<sub>0</sub>,y<sub>0</sub>), ''P<sub>1</sub>'' and ''P<sub>2</sub>''. See: {{slink|Area of a triangle|Using coordinates}}. The expression is equivalent to <math display="inline">h=\frac{2A}{b}</math>, which can be obtained by rearranging the standard formula for the area of a triangle: <math display="inline">A=\frac{1}{2} bh</math>, 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 {{math|1=''P'' = (''P''<sub>x</sub>, ''P''<sub>y</sub>)}} with angle {{math|''θ''}}, then the distance of some point {{math|(''x''<sub>0</sub>, ''y''<sub>0</sub>)}} to the line is
:<math>\operatorname{distance}(P, \theta, (x_0, y_0)) = |\cos(\theta)(P_y-y_0) -\sin(\theta)(P_x-x_0)| </math>
 
==Proofs==
Line 28 ⟶ 32:
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''<sub>0</sub>, ''y''<sub>0</sub>). The line through these two points is perpendicular to the original line, so
:<math>\frac{y_0 - n}{x_0 - m}=\frac{b}{a}.</math>
Thus,
Line 50 ⟶ 54:
This proof is valid only if the line is not horizontal or vertical.<ref>{{harvnb|Ballantine|Jerbert|1952}} do not mention this restriction in their article</ref>
 
Drop a perpendicular from the point ''P'' with coordinates (''x''<sub>0</sub>, ''y''<sub>0</sub>) 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]], 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).<ref>If the two triangles are on opposite sides of the line, these angles are congruent because they are alternate interior angles.</ref> Corresponding sides of these triangles are in the same ratio, so:
:<math>\frac{|\overline{PR}|}{|\overline{PS}|} = \frac{|\overline{TV}|}{|\overline{TU}|}.</math>
If point ''S'' has coordinates (''x''<sub>0</sub>,''m'') then |''PS''| = |''y''<sub>0</sub> - ''m''| and the distance from ''P'' to the line is:
:<math> |\overline{PR} | = \frac{|y_0 - m||B|}{\sqrt{A^2 + B^2}}.</math>
Since ''S'' is on the line, we can find the value of m,
Line 93 ⟶ 97:
:<math>d=\sqrt{ \left( {\frac{x_0 + m y_0-mk}{m^2+1}-x_0 } \right) ^2 + \left( {m\frac{x_0+m y_0-mk}{m^2+1}+k-y_0 }\right) ^2 } = \frac{|k + m x_0 - y_0|}\sqrt{1 + m^2} .</math>
 
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.<ref>{{harvnb|Larson|Hostetler|2007|loc=p. 522}}</ref>
 
==Vector formulation==
Line 112 ⟶ 116:
is a vector that is the [[projection (linear algebra)|projection]] of <math>\mathbf{a}-\mathbf{p}</math> onto the line. Thus
:<math>(\mathbf{a}-\mathbf{p}) - ((\mathbf{a}-\mathbf{p}) \cdot \mathbf{n})\mathbf{n}</math>
is the component of <math>\mathbf{a}-\mathbf{p}</math> perpendicular to the line. The distance from the point to the line is then just the [[norm (mathematics)|norm]] of that vector.<ref>{{cite web|last=Sunday|first=Dan|title=Lines and Distance of a Point to a Line|url=http://geomalgorithms.com/a02-_lines.html|archive-url=https://archive.today/20131206184414/http://geomalgorithms.com/a02-_lines.html|url-status=usurped|archive-date=December 6, 2013|publisher=softSurfer|accessdate=6 December 2013}}</ref> This more general formula is not restricted to two dimensions.
 
== Another vector formulation ==
 
If the vector space is [[orthonormality|orthonormal]] and if the line (''l'' ) goes through point A and has a [[Euclidean vector|direction vector]] <math>\vec u</math>, the distance between point P and line (''l'') is
: <math>d(\mathrm{P}, (l))= \frac{\left\|\overrightarrow{\mathrm{AP}} \times\vec u\right\|}{\|\vec u\|}</math>
where <math>\overrightarrow{\mathrm{AP}} \times\vec u</math> is the [[cross product]] of the vectors <math>\overrightarrow{\mathrm{AP}}</math> and <math>\vec u</math> and where <math>\|\vec u\|</math> is the vector norm of <math>\vec u</math>.
 
<math>\overrightarrow{\mathrm{AP}}=P-A</math>
Note that cross products only exist in dimensions 3 and 7.
 
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]]
* [[Line-lineLine–line intersection]]
* [[Distance between two parallel lines]]
* [[Distance from a point to a plane]]
* [[{{slink|Skew lines#|Distance]]}}
 
==Notes==
Line 134 ⟶ 140:
==References==
* {{citation|first=Howard|last=Anton|title=Elementary Linear Algebra|edition=7th|year=1994|publisher=John Wiley & Sons|isbn=0-471-58742-7}}
* {{citation|first1=J.P.|last1=Ballantine|first2=A.R.|last2=Jerbert|year=1952|volume=59|title=Distance from a line or plane to a point|journal=American Mathematical Monthly|issue=4 |pages=242–243|doi=10.2307/2306514|jstor=2306514 }}
* {{citation|first1=Ron|last1=Larson|first2=Robert|last2=Hostetler|title=Precalculus: A Concise Course|year=2007|publisher=Houghton Mifflin Co.|isbn=978-0-618-62719-76|url-access=registration|url=https://archive.org/details/precalculusconci00lars}}
* {{citation|first=Barry|last=Spain|title=Analytical Conics|year=2007|origyearorig-date=1957|publisher=Dover Publications|isbn=978-0-486-45773-74}}
 
==Further reading==