We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 882a9c0 + 0161fa7 commit 6df2fd9Copy full SHA for 6df2fd9
aima-core/src/main/java/aima/core/util/datastructure/Point2D.java
@@ -42,8 +42,13 @@ public double getY() {
42
* @return the Euclidean distance between a specified point and this point.
43
*/
44
public double distance(Point2D pt) {
45
- double result = (pt.getX() - x) * (pt.getX() - x);
46
- result += (pt.getY() - y) * (pt.getY() - y);
47
- return Math.sqrt(result);
+ // Distance Between X Coordinates
+ double x_distance = (pt.getX() - x) * (pt.getX() - x);
+ // Distance Between Y Coordinates
48
+ double y_distance = (pt.getY()-y)*(pt.getY()-y) ;
49
+ // Distance Between 2d Points
50
+ double total_distance = Math.sqrt(x_distance + y_distance) ;
51
+
52
+ return total_distance ;
53
}
54
0 commit comments