Lesson Distance of a point from a given line in Cartesian Coordinate System
Algebra
->
Coordinate-system
-> Lesson Distance of a point from a given line in Cartesian Coordinate System
Log On
Algebra: Coordinate systems, graph plotting, etc
Section
Solvers
Solvers
Lessons
Lessons
Answers archive
Answers
Source code of 'Distance of a point from a given line in Cartesian Coordinate System'
This Lesson (Distance of a point from a given line in Cartesian Coordinate System)
was created by by
hummingbird(0)
:
View Source
,
Show
About hummingbird
:
In this lesson we will learn about the method of finding the perpendicular distance of a given point<b> {{{P(x[0],y[0])}}}</b> from a given line <b>L1: Y = a.X + b</b> There are several ways of finding the distance of a point from a line. I.e. using co-ordinate geometry, linear algebra and simple trigonometry. In this lesson, we will use trigonometric approach. {{{drawing( 250, 250, -2, 8, -2, 8, line(-2,-2,8,8),line(-1,-1,-1,5),line(-1,5,5,5),green(line(-1,5,2,2)),locate(6,6,L1),locate(3.4,6,L3),locate(-1.8,1.8,L2),locate(-1,6.3,P(x[o],y[o])),locate(-1,-1,A(x[1],y[1])), locate(5,5,B(x[2],y[2])),locate(2,2,C), red(circle(-1,-1,.1)),red(circle(5,5,.1)) ) }}} In the above diagram, Given <A HREF=Mathematical_line.wikipedia>line</A> is {{{L: Y=a*X+b}}} and the given point is {{{P(x[o],y[o])}}}. Now let us look at the construction of the triangle formation in order to obtain the perpendicular distance <b>PC</b>. <b>Methodology</b> We will first find the vertices of the triangle in order to get the side lengths and then by applying <b><A HREF=Sine_rule.wikipedia>Sine Rule</A></b> on triangle <b>PAB</b> and <b>PBC</b> we will calculate the desired distance <b>PC</b>. <b>Step1</b> Draw a vertical line passing through the point P. This line <b>L2:</b> {{{X=x[o]}}} will cut the given line <b>L1</b> at point <b>A</b>( {{{x[1]}}},{{{y[1]}}}). Similarly, draw a horizontal line passing through the point P. This line <b>L3:</b> {{{Y=y[o]}}} will cut the given line <b>L1</b> at point <b>B</b>({{{x[2]}}},{{{y[2]}}}). Now we need to calculate the vertices of the triangle <b>PAB</b> <b>Step2</b> Now we have three lines with following equations: {{{L1: Y=a*X+b}}} {{{L2: X=x[o]}}} {{{L3: Y=y[o]}}} plugging {{{X=x[o]}}} in L1 will give us the point <b>A</b> and similarly plugging {{{Y=y[o]}}} in L1 will give us the point <b>B</b>. Which can be calculated as: A({{{x1=x[o]}}} , {{{y1= a*x[o]+b)}}}) B({{{x2= (y[o]-b)/a}}} , {{{y2=y[o]}}}) <b>Step3</b> Calculate the length of the sides AP,PB and AB of a triangle by the simple <A HREF=Distance_formula.wikipedia>distance formula</A> in two-dimensional geometry. Distance formula :{{{d=sqrt(((x[1]-x[2])^2)+((y[1]-y[2])^2))}}} By this formula we can calculate the side lengths AP,PB and AB. <b>Step4</b> Apply <b>Sine rule</b> on common angle <b>B</b> in triangle <b>PAB</b> and triangle <b>PBC</b>. {{{Sin(B)= AP/AB=PC/BP}}} {{{PC=(AP*BP)/AB}}} Now, Lets plug the distance formula for AP,BP and AB in the above expression {{{PC=(sqrt((yo-(a*x[o]+b))^2)*sqrt((x[o]-((y[o]-b)/a))^2))/sqrt(((x[o]-((y[o]-b)/a))^2)+(((a*x[o]+b)-y[o])^2))}}} This is the final formula in terms of the given parameters xo, yo, a and b. Hence PC is the desired length of a point <b>P</b> from a line <b>L1: Y = a.X + b</b> <b>Alternate Method</b> This Method uses the concept of linear algebra and some advance results on co-ordinate geometry. The perpendicular length of a point {{{P(x[o],y[o])}}} from a line <b> a*X + b*Y + c=0</b> is given by the formula {{{PC=(abs(a*x[o]+b*y[o]+c))/sqrt(a^2+b^2)}}} <b>Note:</b> Here the line is of the form of a*X + b*Y + c=0. We can always change the given equation of line into this standard form and apply the above formula. Also look at the solver based on the above concept. <A HREF=http://www.algebra.com/tutors/Distance_between_a_point_and_a_line.solver?content_action=show_prod> Solver </A>