randRangeNonZero( -3, 3 ) INDEX > 0 ? INDEX * randRangeNonZero( -1, 1 ) : 1 / INDEX * randRangeNonZero( -1, 1 ) decimalFraction( M1, "true", "true" ) M1 > 0 ? "" : "-" -1 / M1 decimalFraction( M2, "true", "true" ) M2 > 0 ? "" : "-" randRange( 2, 8 ) * randRangeNonZero( -1, 1 ) randRange( -8, 8 ) toFraction( M1 )[1] * randRangeNonZero( -3, 3 ) M1 * X1 + B1 round( ( B2 - B1 ) / ( M1 - M2 ), 0 ) M2 * X2 + B2 pow( X1 - X2, 2 ) + pow( Y1 - Y2, 2 )

Find the minimum distance between the point \red{(X1, Y1)} and the line \blue{y = M2_FRAC M2_SIGNx + B2}.

graphInit({ range: [[-10, 10], [-10, 10]], scale: [18, 18], tickStep: 1, labelStep: 1, unityLabels: false, labelFormat: function( s ) { return "\\small{" + s + "}"; }, axisArrows: "<->" }); plot(function( x ) { return ( M2 * x + B2 ); }, [-10, 10], { stroke: BLUE }); circle( [X1, Y1], 1/4, { stroke: "none", fill: RED } );
DISTANCE

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}.

plot(function( x ) { return ( M1 * x + B1 ); }, [-10, 10], { stroke: GREEN });

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.

circle( [X2, Y2], 1/4, { stroke: "none", fill: RED } );

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).

0 99999 randRange( 2, 8 ) * randRangeNonZero( -1, 1 ) 0 randRangeNonZero( -8, 8 ) randRange( -8, 8 ) 0

Find the minimum distance between the point \red{(X1, Y1)} and the line \blue{y = B1}.

graphInit({ range: [[-10, 10], [-10, 10]], scale: [18, 18], tickStep: 1, labelStep: 1, unityLabels: false, labelFormat: function( s ) { return "\\small{" + s + "}"; }, axisArrows: "<->" }); plot(function( x ) { return ( M1 * x + B1 ); }, [-10, 10], { stroke: BLUE }); circle( [X1, Y1], 1/4, { stroke: "none", fill: RED } );

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}.

plot(function( x ) { return ( M2 * ( x - X1 ) ); }, [-10, 10], { stroke: GREEN });

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.

circle( [X1, B1], 1/4, { stroke: "none", fill: RED } );

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 ).

99999 0 randRange( 2, 8 ) * randRangeNonZero( -1, 1 ) 0 randRange( -8, 8 ) randRangeNonZero( -8, 8 ) 0

Find the minimum distance between the point \red{(X1, Y1)} and the line \blue{x = B1}.

graphInit({ range: [[-10, 10], [-10, 10]], scale: [18, 18], tickStep: 1, labelStep: 1, unityLabels: false, labelFormat: function( s ) { return "\\small{" + s + "}"; }, axisArrows: "<->" }); line( [ B1, -10 ], [ B1, 10 ], { stroke: BLUE }); circle( [X1, Y1], 1/4, { stroke: "none", fill: RED } );

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}.

plot(function( x ) { return ( M2 * x + Y1 ); }, [-10, 10], { stroke: GREEN });

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.

circle( [B1, Y1], 1/4, { stroke: "none", fill: RED } );

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 ).