Skip to content

Commit 946bcaa

Browse files
authored
Apply clang-format compliant formatting
1 parent 60e272b commit 946bcaa

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

src/main/java/com/thealgorithms/maths/DistanceBetweenTwoPoints.java

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
/**
44
* Distance Between Two Points in 2D Space.
55
*
6-
* <p>This class provides a method to calculate the Euclidean distance
7-
* between two points in a two-dimensional plane.</p>
6+
* <p>This class provides a method to calculate the Euclidean distance between two points in a
7+
* two-dimensional plane.
88
*
9-
* <p>Formula:
10-
* d = √((x2 − x1)² + (y2 − y1)²)</p>
9+
* <p>Formula: d = sqrt((x2 - x1)^2 + (y2 - y1)^2)
1110
*
12-
* <p>Reference:
13-
* https://en.wikipedia.org/wiki/Euclidean_distance</p>
11+
* <p>Reference: https://en.wikipedia.org/wiki/Euclidean_distance
1412
*/
1513
public final class DistanceBetweenTwoPoints {
1614

@@ -28,13 +26,9 @@ private DistanceBetweenTwoPoints() {
2826
* @return Euclidean distance between the two points
2927
*/
3028
public static double calculate(
31-
final double x1,
32-
final double y1,
33-
final double x2,
34-
final double y2) {
35-
36-
return Math.sqrt(
37-
Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2)
38-
);
29+
final double x1, final double y1, final double x2, final double y2) {
30+
final double deltaX = x2 - x1;
31+
final double deltaY = y2 - y1;
32+
return Math.sqrt(deltaX * deltaX + deltaY * deltaY);
3933
}
4034
}

0 commit comments

Comments
 (0)