public boolean intersect(Bounds boundsObject, BoundingBox newBoundBox) {
boolean intersect(Point3d origin, Vector3d direction, Point4d position ) { double t1,t2,tmp,tnear,tfar,invDir,invMag; double dirx, diry, dirz;    if( boundsIsEmpty ) { return false; }
    public boolean intersect(Bounds boundsObject, BoundingBox newBoundBox) {	if((boundsObject == null) || boundsIsEmpty || boundsObject.boundsIsEmpty ) {	    // Negative volume.	    newBoundBox.setLower( 1.0d,  1.0d,  1.0d);	    newBoundBox.setUpper(-1.0d, -1.0d, -1.0d);	    return false;        }	if(boundsIsInfinite && (!boundsObject.boundsIsInfinite)) {	    newBoundBox.set(boundsObject);	    return true;	}	else if((!boundsIsInfinite) && boundsObject.boundsIsInfinite) {	    newBoundBox.set(this);	    return true;	}	else if(boundsIsInfinite && boundsObject.boundsIsInfinite) {	    newBoundBox.set(this);	    return true;	}	else if( boundsObject.boundId == BOUNDING_BOX){	    BoundingBox box = (BoundingBox)boundsObject;	    // both boxes are axis aligned	    if( upper.x > box.lower.x && box.upper.x > lower.x &&		upper.y > box.lower.y && box.upper.y > lower.y &&		upper.z > box.lower.z && box.upper.z > lower.z ){               		if(upper.x > box.upper.x) 		    newBoundBox.upper.x = box.upper.x; 		else		    newBoundBox.upper.x = upper.x; 		if(upper.y > box.upper.y) 		    newBoundBox.upper.y = box.upper.y; 		else		    newBoundBox.upper.y = upper.y; 		if(upper.z > box.upper.z) 		    newBoundBox.upper.z = box.upper.z; 		else		    newBoundBox.upper.z = upper.z; 		if(lower.x < box.lower.x) 		    newBoundBox.lower.x = box.lower.x; 		else		    newBoundBox.lower.x = lower.x; 		if(lower.y < box.lower.y) 		    newBoundBox.lower.y = box.lower.y; 		else		    newBoundBox.lower.y = lower.y; 		if(lower.z < box.lower.z) 		    newBoundBox.lower.z = box.lower.z; 		else		    newBoundBox.lower.z = lower.z; 		newBoundBox.updateBoundsStates();		return true;	    } else {		// Negative volume.		newBoundBox.setLower( 1.0d,  1.0d,  1.0d);		newBoundBox.setUpper(-1.0d, -1.0d, -1.0d);		return false;	    }        }	else if( boundsObject.boundId == BOUNDING_SPHERE) {	    BoundingSphere sphere = (BoundingSphere)boundsObject;	    if( this.intersect( sphere) ) {		BoundingBox sbox = new BoundingBox( sphere );		this.intersect( sbox, newBoundBox );		return true;	    } else {		// Negative volume.		newBoundBox.setLower( 1.0d,  1.0d,  1.0d);		newBoundBox.setUpper(-1.0d, -1.0d, -1.0d);		return false;	    }	                //      System.out.println("intersect Sphere ");        }	else if(boundsObject.boundId == BOUNDING_POLYTOPE) {	    BoundingPolytope polytope = (BoundingPolytope)boundsObject;	    if( this.intersect( polytope)) {		BoundingBox pbox = new BoundingBox( polytope); // convert polytope to box		this.intersect( pbox, newBoundBox );		return true;	    } else {		// Negative volume.		newBoundBox.setLower( 1.0d,  1.0d,  1.0d);		newBoundBox.setUpper(-1.0d, -1.0d, -1.0d);		return false;	    }        } else {            throw new IllegalArgumentException(J3dI18N.getString("BoundingBox7"));            }        }