diff --git a/src/main/java/com/massivecraft/factions/FLocation.java b/src/main/java/com/massivecraft/factions/FLocation.java index ee026c7a..c64bb8bf 100644 --- a/src/main/java/com/massivecraft/factions/FLocation.java +++ b/src/main/java/com/massivecraft/factions/FLocation.java @@ -131,10 +131,18 @@ public class FLocation { return Math.sqrt(dx * dx + dz * dz); } + public double getDistanceSquaredTo(FLocation that) { + double dx = that.x - this.x; + double dz = that.z - this.z; + return dx * dx + dz * dz; + } + //----------------------------------------------// // Some Geometry //----------------------------------------------// public Set getCircle(double radius) { + double radiusSquared = radius * radius; + Set ret = new LinkedHashSet(); if (radius <= 0) { return ret; @@ -148,7 +156,7 @@ public class FLocation { for (int x = xfrom; x <= xto; x++) { for (int z = zfrom; z <= zto; z++) { FLocation potential = new FLocation(this.worldName, x, z); - if (this.getDistanceTo(potential) <= radius) { + if (this.getDistanceSquaredTo(potential) <= radiusSquared) { ret.add(potential); } }