public static Bbox intersection ( Bbox one , Bbox two ) { if ( ! intersects ( one , two ) ) { return null ; } else { double minx = two . getX ( ) > one . getX ( ) ? two . getX ( ) : one . getX ( ) ; double maxx = two . getMaxX ( ) < one . getMaxX ( ) ? two . getMaxX ( ) : one . getMaxX ( ) ; double miny = two . getY ( ) > one . getY ( ) ? two . getY ( ) : one . getY ( ) ; double maxy = two . getMaxY ( ) < one . getMaxY ( ) ? two . getMaxY ( ) : one . getMaxY ( ) ; return new Bbox ( minx , miny , ( maxx - minx ) , ( maxy - miny ) ) ; } }
Calculates the intersection between 2 bounding boxes .