/** * Calculates distance from this position to given position. * * @param pos Compared position * @return Distance */ public double getDistanceTo(Position pos) { return Math.sqrt( Math.abs(coords[0] - pos.getXCoordinate()) * Math.abs(coords[0] - pos.getXCoordinate()) + Math.abs(coords[1] - pos.getYCoordinate()) * Math.abs(coords[1] - pos.getYCoordinate()) + Math.abs(coords[2] - pos.getZCoordinate()) * Math.abs(coords[2] - pos.getZCoordinate())); }