private final void unionBox(Rectangle3D bbox) { if (bbox.isEmpty()) return; Rectangle3D tbox = bbox.transformByMatrix(null, currentTrafo); double[][] bnds = tbox.getBounds(); bound.xmin = Math.min(bound.xmin, bnds[0][0]); bound.xmax = Math.max(bound.xmax, bnds[1][0]); bound.ymin = Math.min(bound.ymin, bnds[0][1]); bound.ymax = Math.max(bound.ymax, bnds[1][1]); bound.zmin = Math.min(bound.zmin, bnds[0][2]); bound.zmax = Math.max(bound.zmax, bnds[1][2]); }
/** Convert result into Rectangle3D instance (see {@link de.jreality.util.Rectangle3D} */ public Rectangle3D getBoundingBox() { Rectangle3D rect3d = new Rectangle3D(); double[][] bnds = rect3d.getBounds(); bnds[0][0] = getXmin(); bnds[1][0] = getXmax(); bnds[0][1] = getYmin(); bnds[1][1] = getYmax(); bnds[0][2] = getZmin(); bnds[1][2] = getZmax(); rect3d.setBounds(bnds); if (Rn.isNan(bnds[0]) || Rn.isNan(bnds[1])) return Rectangle3D.EMPTY_BOX; return rect3d; }