You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2018/07/21 10:07:40 UTC
[commons-geometry] 02/15: using built-in Math.hypot() method for 2D
Euclidean distance calculation
This is an automated email from the ASF dual-hosted git repository.
erans pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-geometry.git
commit abb1a9778ac0b35d048ff7b4e3e522548a009a81
Author: Matt Juntunen <ma...@hotmail.com>
AuthorDate: Thu Jun 21 23:45:49 2018 -0400
using built-in Math.hypot() method for 2D Euclidean distance calculation
---
.../org/apache/commons/geometry/euclidean/twod/Cartesian2D.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Cartesian2D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Cartesian2D.java
index 8710b3e..a1a9785 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Cartesian2D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Cartesian2D.java
@@ -96,8 +96,8 @@ public abstract class Cartesian2D implements Spatial, Serializable {
* @return Euclidean distance
*/
protected double euclideanDistance(Cartesian2D other) {
- double dx = x - other.x;
- double dy = y - other.y;
- return Math.sqrt((dx * dx) + (dy * dy));
+ final double dx = x - other.x;
+ final double dy = y - other.y;
+ return Math.hypot(dx, dy);
}
}