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;
  }
  public void alignContent() {
    try {
      bounds = calculateBoundingBox(wrap(content));
    } catch (Exception e) {
      return;
    }
    removeZeroExtends(bounds);
    double scale = 1;
    double[] e = bounds.getExtent();
    double[] center = bounds.getCenter();
    double objectSize = Math.max(Math.max(e[0], e[1]), e[2]);
    scale = contentSize / objectSize;
    Matrix matrix = MatrixBuilder.euclidean().scale(scale).getMatrix();

    matrix.assignTo(scalingComponent);

    bounds = bounds.transformByMatrix(bounds, matrix.getArray());
    center = bounds.getCenter();

    FactoredMatrix factoredMatrix = new FactoredMatrix(transformationComponent.getTransformation());
    double angle = factoredMatrix.getRotationAngle();
    double[] axis = factoredMatrix.getRotationAxis();

    Matrix m =
        MatrixBuilder.euclidean()
            .translate(0, verticalOffset, 0)
            .rotate(angle, axis)
            .translate(-center[0], -bounds.getMinY(), -center[2])
            .getMatrix();
    m.assignTo(transformationComponent);
    bounds = bounds.transformByMatrix(bounds, m.getArray());
  }