コード例 #1
0
 public boolean intersects(BaseBounds other) {
   if ((other == null) || other.isEmpty() || isEmpty()) {
     return false;
   }
   return (other.getMaxX() >= minX
       && other.getMaxY() >= minY
       && other.getMaxZ() >= getMinZ()
       && other.getMinX() <= maxX
       && other.getMinY() <= maxY
       && other.getMinZ() <= getMaxZ());
 }
コード例 #2
0
  @Override
  public void intersectWith(BaseBounds other) {
    // Short circuit intersect if either bounds is empty.
    if (this.isEmpty()) return;
    if (other.isEmpty()) {
      makeEmpty();
      return;
    }

    minX = Math.max(minX, other.getMinX());
    minY = Math.max(minY, other.getMinY());
    maxX = Math.min(maxX, other.getMaxX());
    maxY = Math.min(maxY, other.getMaxY());
  }
コード例 #3
0
 @Override
 public BaseBounds deriveWithNewBounds(BaseBounds other) {
   if (other.isEmpty()) return makeEmpty();
   if (other.getBoundsType() == BoundsType.RECTANGLE) {
     RectBounds rb = (RectBounds) other;
     minX = rb.getMinX();
     minY = rb.getMinY();
     maxX = rb.getMaxX();
     maxY = rb.getMaxY();
   } else if (other.getBoundsType() == BoundsType.BOX) {
     return new BoxBounds((BoxBounds) other);
   } else {
     throw new UnsupportedOperationException("Unknown BoundsType");
   }
   return this;
 }