示例#1
0
  /**
   * intersect with an aabox
   *
   * @param b
   */
  public void intersection(BBox b) {
    if (this.min.getX() < b.getMin().getX()) this.min.setX(b.getMin().getX());
    if (this.min.getY() < b.getMin().getY()) this.min.setY(b.getMin().getY());
    if (this.min.getZ() < b.getMin().getZ()) this.min.setZ(b.getMin().getZ());

    if (this.max.getX() > b.getMax().getX()) this.max.setX(b.getMax().getX());
    if (this.max.getY() > b.getMax().getY()) this.max.setY(b.getMax().getY());
    if (this.max.getZ() > b.getMax().getZ()) this.max.setZ(b.getMax().getZ());
  }
示例#2
0
  /**
   * add a aabox
   *
   * @param b
   */
  public void union(BBox b) {
    if (b.getMin().getX() < this.min.getX()) this.min.setX(b.getMin().getX());
    if (b.getMin().getY() < this.min.getY()) this.min.setY(b.getMin().getY());
    if (b.getMin().getZ() < this.min.getZ()) this.min.setZ(b.getMin().getZ());

    if (b.getMax().getX() > this.max.getX()) this.max.setX(b.getMax().getX());
    if (b.getMax().getY() > this.max.getY()) this.max.setY(b.getMax().getY());
    if (b.getMax().getZ() > this.max.getZ()) this.max.setZ(b.getMax().getZ());
  }
示例#3
0
  /**
   * add a point into the aabox
   *
   * @param sensation
   * @param p
   * @return the new aabox
   */
  public static BBox union(BBox sensation, Point p) {
    BBox ret = sensation;

    if (sensation.getMin().getX() > p.getX()) ret.getMin().setX(p.getX());
    if (sensation.getMin().getY() > p.getY()) ret.getMin().setY(p.getY());
    if (sensation.getMin().getZ() > p.getZ()) ret.getMin().setZ(p.getZ());

    if (sensation.getMax().getX() < p.getX()) ret.getMax().setX(p.getX());
    if (sensation.getMax().getY() < p.getY()) ret.getMax().setY(p.getY());
    if (sensation.getMax().getZ() < p.getZ()) ret.getMax().setZ(p.getZ());

    return ret;
  }
示例#4
0
  /**
   * intersect of two aaboxes
   *
   * @param b
   * @param c
   * @return the intersect aabox
   */
  public static BBox intersection(BBox b, BBox c) {
    BBox ret = new BBox();

    if (b.getMin().getX() > c.getMin().getX()) ret.getMin().setX(b.getMin().getX());
    else ret.getMin().setX(c.getMin().getX());

    if (b.getMin().getY() > c.getMin().getY()) ret.getMin().setY(b.getMin().getY());
    else ret.getMin().setY(c.getMin().getY());

    if (b.getMin().getZ() > c.getMin().getZ()) ret.getMin().setZ(b.getMin().getZ());
    else ret.getMin().setZ(c.getMin().getZ());

    if (b.getMax().getX() < c.getMax().getX()) ret.getMax().setX(b.getMax().getX());
    else ret.getMax().setX(c.getMax().getX());

    if (b.getMax().getY() < c.getMax().getY()) ret.getMax().setY(b.getMax().getY());
    else ret.getMax().setY(c.getMax().getY());

    if (b.getMax().getZ() < c.getMax().getZ()) ret.getMax().setZ(b.getMax().getZ());
    else ret.getMax().setZ(c.getMax().getZ());

    return ret;
  }
示例#5
0
 /**
  * check the intersect of two aabox
  *
  * @param b
  * @return
  */
 public boolean overlaps(BBox b) {
   boolean x = (this.max.getX() >= b.getMin().getX()) && (this.min.getX() <= b.getMax().getX());
   boolean y = (this.max.getY() >= b.getMin().getY()) && (this.min.getY() <= b.getMax().getY());
   boolean z = (this.max.getZ() >= b.getMin().getZ()) && (this.min.getZ() <= b.getMax().getZ());
   return (x && y && z);
 }