Based on the @trashgod’s comment, this is the simpliest way to calculate distance:
double distance = Math.hypot(x1-x2, y1-y2);
From documentation of Math.hypot
:
Returns:
sqrt(x²+ y²)
without intermediate overflow or underflow.
Based on the @trashgod’s comment, this is the simpliest way to calculate distance:
double distance = Math.hypot(x1-x2, y1-y2);
From documentation of Math.hypot
:
Returns:
sqrt(x²+ y²)
without intermediate overflow or underflow.