Find the distance between the points (X1, Y1) and (X2, Y2).
Change in x
:
X2 - negParens(X1)
X1 - negParens(X2)
= X_DIST
Change in y
:
Y2 - negParens(Y1)
Y1 - negParens(Y2)
= Y_DIST
The distance is the length of the hypotenuse of this right triangle.
By the Pythagorean Theorem, that length is equal to:
\sqrt{X_DIST^2 + Y_DIST^2}
{}= \sqrt{Math.pow( X_DIST, 2 ) + pow( Y_DIST, 2 )}
{}= formattedSquareRootOf(HYP2)
The distance is equal to the length of the side, which is X_DIST+Y_DIST