SyntaxFix
Write A Post
Hire A Developer
Questions
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:
Math.hypot
Returns: sqrt(x²+ y²) without intermediate overflow or underflow.
sqrt(x²+ y²)