Created
June 14, 2019 15:49
-
-
Save Battleroid/ae0eeeeca3ac88f0ff3e05072760b6a0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/SNode.java b/src/SNode.java | |
index fcd7775..0554a07 100644 | |
--- a/src/SNode.java | |
+++ b/src/SNode.java | |
@@ -49,17 +49,15 @@ public class SNode implements Comparable<SNode> { | |
} | |
static public double distanceTo(SNode f, SNode t) { | |
- double dx = Math.abs(f.x - t.x); | |
- double dy = Math.abs(f.y- t.y); | |
- return d * (dx + dy) + (d2 - 2 * d) * Math.min(dx, dy); | |
+ return Math.sqrt(Math.pow(t.x - f.x, 2.0) + Math.pow(t.y - f.y, 2.0)); | |
} | |
public double distanceTo(SNode snode) { | |
- return Math.abs(x - snode.getX()) + Math.abs(y - snode.getY()); | |
+ return Math.sqrt(Math.pow(snode.getX() - x, 2) + Math.pow(snode.getY() - y, 2)); | |
} | |
public double distanceTo(double x, double y) { | |
- return Math.abs(this.x - x) + Math.abs(this.y - y); | |
+ return Math.sqrt(Math.pow(x - this.x, 2) + Math.pow(y - this.y, 2)); | |
} | |
/** |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment