public static BoundaryBox clip(BoundaryBox bb, int minX, int minY, int maxX, int maxY){
		int newX = Math.min(Math.max(minX, bb.getX()), maxX);
		int newY = Math.min(Math.max(minY, bb.getY()), maxY);
		
		int endX = Math.min(Math.max(minX, bb.getX()+bb.getWidth()), maxX);
		int endY = Math.min(Math.max(minY, bb.getY()+bb.getHeight()), maxY);
		
		return new BoundaryBox(newX, newY, endX-newX, endY-newY);
		
		
	}