add comments to DhBlockPos and Pos2D
This commit is contained in:
@@ -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<Br>
|
||||
* or determine the taxi cab (manhattan) distance between two points. <Br><Br>
|
||||
*
|
||||
* 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());
|
||||
|
||||
@@ -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 <br><br>
|
||||
*
|
||||
* Example chebyshev distance between X and every point around it: <br>
|
||||
* <code>
|
||||
* 2 2 2 2 2 <br>
|
||||
* 2 1 1 1 2 <br>
|
||||
* 2 1 X 1 2 <br>
|
||||
* 2 1 1 1 2 <br>
|
||||
* 2 2 2 2 2 <br>
|
||||
* </code>
|
||||
* */
|
||||
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<Br>
|
||||
* or determine the taxi cab (manhattan) distance between two points. <Br><Br>
|
||||
*
|
||||
* 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); }
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user