public void expand(final Shape s) { Prism r = s.getMBR(); if (r.t1 < this.t1) this.t1 = r.t1; if (r.t2 > this.t2) this.t2 = r.t2; if (r.x1 < this.x1) this.x1 = r.x1; if (r.x2 > this.x2) this.x2 = r.x2; if (r.y1 < this.y1) this.y1 = r.y1; if (r.y2 > this.y2) this.y2 = r.y2; }
public Prism union(final Shape s) { Prism r = s.getMBR(); double ut1 = Math.min(t1, r.t1); double ut2 = Math.max(t2, r.t2); double ux1 = Math.min(x1, r.x1); double ux2 = Math.max(x2, r.x2); double uy1 = Math.min(y1, r.y1); double uy2 = Math.max(y2, r.y2); return new Prism(ut1, ux1, uy1, ut2, ux2, uy2); }
public Prism getIntersection(Shape s) { if (!s.isIntersected(this)) return null; Prism r = s.getMBR(); double it1 = Math.max(this.t1, r.t1); double it2 = Math.min(this.t2, r.t2); double ix1 = Math.max(this.x1, r.x1); double ix2 = Math.min(this.x2, r.x2); double iy1 = Math.max(this.y1, r.y1); double iy2 = Math.min(this.y2, r.y2); return new Prism(it1, ix1, iy1, it2, ix2, iy2); }
public boolean isIntersected(Shape s) { if (s instanceof Point3d) { Point3d pt = (Point3d) s; return pt.t >= t1 && pt.t <= t2 && pt.x >= x1 && pt.x <= x2 && pt.y >= y1 && pt.y <= y2; } Prism r = s.getMBR(); if (r == null) return false; return (this.t2 > r.t1 && r.t2 > this.t1 && this.x2 > r.x1 && r.x2 > this.x1 && this.y2 > r.y1 && r.y2 > this.y1); }
public void set(Shape s) { Prism mbr = s.getMBR(); set(mbr.t1, mbr.x1, mbr.y1, mbr.t2, mbr.x2, mbr.y2); }