Permalink
Browse files

Fix off-by-one in area calculation.

Even the volume calculation had it correct.
Also fix code style in contains.
  • Loading branch information...
wizjany committed Jan 21, 2018
1 parent 0f72811 commit 3a332fd87d6b0231a90d9a84dafcf038e63704fe
@@ -125,9 +125,9 @@ public boolean contains(Vector pt) {
final double x = pt.getX();
final double y = pt.getY();
final double z = pt.getZ();
return x >= min.getBlockX() && x < max.getBlockX()+1
&& y >= min.getBlockY() && y < max.getBlockY()+1
&& z >= min.getBlockZ() && z < max.getBlockZ()+1;
return x >= min.getBlockX() && x < max.getBlockX() + 1
&& y >= min.getBlockY() && y < max.getBlockY() + 1
&& z >= min.getBlockZ() && z < max.getBlockZ() + 1;
}
@Override
@@ -139,8 +139,8 @@ public RegionType getType() {
Area toArea() {
int x = getMinimumPoint().getBlockX();
int z = getMinimumPoint().getBlockZ();
int width = getMaximumPoint().getBlockX() - x;
int height = getMaximumPoint().getBlockZ() - z;
int width = getMaximumPoint().getBlockX() - x + 1;
int height = getMaximumPoint().getBlockZ() - z + 1;
return new Area(new Rectangle(x, z, width, height));
}
@@ -172,4 +172,4 @@ public int volume() {
}
}
}
}

0 comments on commit 3a332fd

Please sign in to comment.