Distance from a point to a line: Difference between revisions

Content deleted Content added
algebraic expression
distance formula for Line defined by two points correction
Line 22:
== Line defined by two points ==
If the line passes through two points {{math|1=''P''<sub>1</sub> = (''x''<sub>1</sub>, ''y''<sub>1</sub>)}} and {{math|1=''P''<sub>2</sub> = (''x<sub>2</sub>'', ''y<sub>2</sub>'')}} then the distance of {{math|(''x''<sub>0</sub>, ''y''<sub>0</sub>)}} from the line is:<ref name=GEO />
:<math>\operatorname{distance}(P_1, P_2, (x_0, y_0)) = \frac{|(x_2-x_1)(y_1-y_0-y_1)-(x_1-x_0-x_1)(y_2-y_1)|}{\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}}. </math>
 
The denominator of this expression is the distance between {{math|''P''<sub>1</sub>}} and {{math|''P''<sub>2</sub>}}. The numerator is twice the area of the triangle with its vertices at the three points, {{math|(''x''<sub>0</sub>, ''y''<sub>0</sub>)}}, {{math|''P''<sub>1</sub>}} and {{math|''P''<sub>2</sub>}}. See: {{slink|Area of a triangle|Using coordinates}}. The expression is equivalent to {{math|1=''h'' = {{sfrac|2''A''|''b''}}}}, which can be obtained by rearranging the standard formula for the area of a triangle: {{math|1=''A'' = {{sfrac|1|2}} ''bh''}}, where {{mvar|b}} is the length of a side, and {{mvar|h}} is the perpendicular height from the opposite vertex.