Find the minimum distance between the point \red{(X1, Y1)}
and the line \blue{y =
M2_FRAC
M2_SIGNx
+ B2}.
First, find the equation of the perpendicular line that passes through \red{(X1, Y1)}.
The slope of the blue line is \blue{M2_FRAC},
and its negative reciprocal is \green{M1_FRAC}.
Thus, the equation of our perpendicular line will be of the form \green{y =
M1_FRAC
M1_SIGNx + b}.
We can plug our point, \red{(X1, Y1)},
into this equation to solve for \green{b}, the y-intercept.
Y1 = \green{
M1_FRAC
M1_SIGN}(X1) + \green{b}
Y1 = decimalFraction( M1 * X1, "true", "true" ) + \green{b}
Y1 - decimalFraction( M1 * X1, "true", "true" ) = \green{b} = decimalFraction( Y1 - M1 * X1, "true", "true" )
The equation of the perpendicular line is \green{y =
M1_FRAC
M1_SIGNx
+ B1}.
We can see from the graph (or by setting the equations equal to one another) that the two lines intersect at the point \red{(X2, Y2)}. Thus, the distance we're looking for is the distance between the two red points.
The distance between two points is: \sqrt{( x_{1} - x_{2} )^2 + ( y_{1} - y_{2} )^2}
Plugging in our points \red{(X1, Y1)} and \red{(X2, Y2)} gives us: \sqrt{( \red{X1} - \red{X2} )^2 + ( \red{Y1} - \red{Y2} )^2}
= \sqrt{( X1 - X2 )^2 + ( Y1 - Y2 )^2} = \sqrt{DISTANCE} = formattedSquareRootOf( DISTANCE )
So the minimum distance between the point \red{(X1, Y1)}
and the line \blue{y =
M2_FRAC
M2_SIGNx
+ B2}
is formattedSquareRootOf(DISTANCE).
Find the minimum distance between the point \red{(X1, Y1)}
and the line \blue{y = B1}.
pow( Y1 - B1, 2 )
First, find the equation of the perpendicular line that passes through \red{(X1, Y1)}.
Since the slope of the blue line is \blue{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 \red{(X1, Y1)} is \green{x = X1}.
We can see from the graph that the two lines intersect at the point \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:
|\red{Y1} - ( \red{B1} )| = abs( Y1 - B1 )
So the minimum distance between the point \red{(X1, Y1)} and the line \blue{y = B1} is abs( Y1 - B1 ).
Find the minimum distance between the point \red{(X1, Y1)}
and the line \blue{x = B1}.
pow( X1 - B1, 2 )
First, find the equation of the perpendicular line that passes through \red{(X1, Y1)}.
Since the blue line has an infinite slope, the perpendicular line will have a slope of \green{0} and therefore will be a horizontal line.
The equation of the perpendicular line that passes through \red{(X1, Y1)} is \green{y = Y1}.
We can see from the graph that the two lines intersect at the point \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:
|\red{X1} - ( \red{B1} )| = abs( X1 - B1 )
So the minimum distance between the point \red{(X1, Y1)} and the line \blue{x = B1}is abs( X1 - B1 ).