diff --git a/core/src/main/java/com/seibel/lod/core/pos/DhBlockPos.java b/core/src/main/java/com/seibel/lod/core/pos/DhBlockPos.java index 48c346285..206dd7523 100644 --- a/core/src/main/java/com/seibel/lod/core/pos/DhBlockPos.java +++ b/core/src/main/java/com/seibel/lod/core/pos/DhBlockPos.java @@ -114,7 +114,14 @@ public class DhBlockPos { { return new DhBlockPos(this.x + x, this.y + y, this.z + z); } - + + /** + * Can be used to quickly determine the rough distance between two points
+ * or determine the taxi cab (manhattan) distance between two points.

+ * + * Manhattan distance is equivalent to determining the distance between two street intersections, + * where you can only drive along each street, instead of directly to the other point. + */ public int getManhattanDistance(DhBlockPos otherPos) { return Math.abs(this.getX() - otherPos.getX()) + Math.abs(this.getY() - otherPos.getY()) + Math.abs(this.getZ() - otherPos.getZ()); diff --git a/core/src/main/java/com/seibel/lod/core/pos/Pos2D.java b/core/src/main/java/com/seibel/lod/core/pos/Pos2D.java index 7ed5dda58..577e74fec 100644 --- a/core/src/main/java/com/seibel/lod/core/pos/Pos2D.java +++ b/core/src/main/java/com/seibel/lod/core/pos/Pos2D.java @@ -47,8 +47,29 @@ public class Pos2D public double dist(Pos2D other) { return Math.sqrt(Math.pow(this.x - other.x, 2) + Math.pow(this.y - other.y, 2)); } public long distSquared(Pos2D other) { return MathUtil.pow2((long) this.x - other.x) + MathUtil.pow2((long) this.y - other.y); } + + /** + * Returns the maximum distance along either the X or Z axis

+ * + * Example chebyshev distance between X and every point around it:
+ * + * 2 2 2 2 2
+ * 2 1 1 1 2
+ * 2 1 X 1 2
+ * 2 1 1 1 2
+ * 2 2 2 2 2
+ *
+ * */ public int chebyshevDist(Pos2D other) { return Math.max(Math.abs(this.x - other.x), Math.abs(this.y - other.y)); } - public int manhattanDist(Pos2D o) { return Math.abs(this.x - o.x) + Math.abs(this.y - o.y); } + + /** + * Can be used to quickly determine the rough distance between two points
+ * or determine the taxi cab (manhattan) distance between two points.

+ * + * Manhattan distance is equivalent to determining the distance between two street intersections, + * where you can only drive along each street, instead of directly to the other point. + */ + public int manhattanDist(Pos2D other) { return Math.abs(this.x - other.x) + Math.abs(this.y - other.y); }