Find the distance between the point \color{red}{(X1, Y1)} and the line \enspace \color{BLUE}{y = M2_FRACM2_SIGNx + B2}\thinspace.
DISTANCE
First, find the equation of the perpendicular line that passes through \color{red}{(X1, Y1)}.
The slope of the blue line is \color{BLUE}{M2_FRAC}, and its negative reciprocal is \color{GREEN}{M1_FRAC}.
Thus, the equation of our perpendicular line will be of the form \enspace \color{GREEN}{y = M1_FRACM1_SIGNx + b}\thinspace.
We can plug our point, \color{red}{(X1, Y1)}, into this equation to solve for \color{GREEN}{b}, the y-intercept.
Y1 = \color{GREEN}{M1_FRACM1_SIGN}(X1) + \color{GREEN}{b}
Y1 = decimalFraction( M1 * X1, "true", "true" ) + \color{GREEN}{b}
Y1 - decimalFraction( M1 * X1, "true", "true" ) = \color{GREEN}{b} = decimalFraction( Y1 - M1 * X1, "true", "true" )
The equation of the perpendicular line is \enspace \color{GREEN}{y = M1_FRACM1_SIGNx + B1}\thinspace.
We can see from the graph (or by setting the equations equal to one another) that the two lines intersect at the point \color{red}{(X2, Y2)}. Thus, the distance we're looking for is the distance between the two red points.
The distance formula tells us that the distance between two points is equal to: \sqrt{( x_{1} - x_{2} )^2 + ( y_{1} - y_{2} )^2}
Plugging in our points \color{red}{(X1, Y1)} and \color{red}{(X2, Y2)} gives us: \sqrt{( \color{red}{X1} - \color{red}{X2} )^2 + ( \color{red}{Y1} - \color{red}{Y2} )^2}
= \sqrt{( X1 - X2 )^2 + ( Y1 - Y2 )^2} = \sqrt{DISTANCE} = formattedSquareRootOf( DISTANCE )
The distance between the point \color{red}{(X1, Y1)} and the line \thinspace \color{BLUE}{y = M2_FRACM2_SIGNx + B2}\enspace is \thinspaceformattedSquareRootOf( DISTANCE ).
Find the distance between the point \color{red}{(X1, Y1)} and the line \enspace \color{BLUE}{y = B1}\thinspace.
pow( Y1 - B1, 2 )
First, find the equation of the perpendicular line that passes through \color{red}{(X1, Y1)}.
Since the slope of the blue line is 0, the perpendicular line will have an infinite slope and therefore will be a vertical line.
The equation of the vertical line that passes through \color{red}{(X1, Y1)} is \enspace \color{GREEN}{x = X1}\thinspace.
We can see from the graph that the two lines intersect at the point \color{red}{(X1, B1)}. Thus, the distance we're looking for is the distance between the two red points.
Since their x components are the same, the distance between the two points is simply the change in y:
|\color{red}{Y1} - ( \color{red}{B1} )| = abs( Y1 - B1 )
The distance between the point \color{red}{(X1, Y1)} and the line \enspace \color{BLUE}{y = B1}\enspace is \thinspaceabs( Y1 - B1 ).
Find the distance between the point \color{red}{(X1, Y1)} and the line \enspace \color{BLUE}{x = B1}\thinspace.
pow( X1 - B1, 2 )
First, find the equation of the perpendicular line that passes through \color{red}{(X1, Y1)}.
Since the blue line has an infinite slope, the perpendicular line will have a slope of \color{GREEN}{0} and therefore will be a horizontal line.
The equation of the perpendicular line that passes through \color{red}{(X1, Y1)} is \enspace \color{GREEN}{y = Y1}\thinspace.
We can see from the graph that the two lines intersect at the point \color{red}{(B1, Y1)}. Thus, the distance we're looking for is the distance between the two red points.
Since their y components are the same, the distance between the two points is simply the change in x:
|\color{red}{X1} - ( \color{red}{B1} )| = abs( X1 - B1 )
The distance between the point \color{red}{(X1, Y1)} and the line \enspace \color{BLUE}{x = B1}\enspace is \thinspaceabs( X1 - B1 ).