示例#1
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());
  }
示例#2
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());
  }
示例#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
 /**
  * Uniformly scales all vertices by multiplying with the value m.
  *
  * @param m Factor to scale by.
  * @return Returns reference to self
  */
 public UVertexList scale(float m) {
   for (int i = 0; i < n; i++) v[i].mult(m);
   if (bb != null) bb.scale(m);
   w *= m;
   h *= m;
   d *= m;
   return this;
 }
示例#5
0
  public boolean contains(BBox b) {
    if (bbox.contains(b)) {
      return contains(b.maxLat, b.minLon)
          && contains(b.minLat, b.minLon)
          && contains(b.maxLat, b.maxLon)
          && contains(b.minLat, b.maxLon);
    }

    return false;
  }
示例#6
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;
  }
示例#7
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);
 }
示例#8
0
 /**
  * Scales XYZ dimensions of all vertices by multiplying them with individual factors.
  *
  * @param mx Factor to scale X values.
  * @param my Factor to scale Y values.
  * @param mz Factor to scale Z values.
  * @return Returns reference to self
  */
 public UVertexList scale(float mx, float my, float mz) {
   for (int i = 0; i < n; i++) v[i].mult(mx, my, mz);
   if (bb != null) bb.translate(mx, my, mz);
   return this;
 }
示例#9
0
 /**
  * Translates all vertices by adding x,y,z to each vertex.
  *
  * @return
  */
 public UVertexList translate(float x, float y, float z) {
   for (int i = 0; i < n; i++) v[i].add(x, y, z);
   if (bb != null) bb.translate(x, y, z);
   return this;
 }
示例#10
0
 /**
  * Translates all vertices by adding the values of _v to each vertex.
  *
  * @param _v Vector to add.
  * @return
  */
 public UVertexList translate(UVec3 _v) {
   for (int i = 0; i < n; i++) v[i].add(_v);
   if (bb != null) bb.translate(_v);
   return this;
 }
示例#11
0
  /**
   * Calculates bounding box
   *
   * @return Returns reference to self
   */
  public UVertexList calcBounds() {
    if (bb == null) bb = new BBox();
    bb.calc(this, true);

    return this;
  }