/** * Determines whether two boxes describe the same region. * <p> * Two boxes are equal iff they have the same dimensionality, boundary type, * lengths and position. * </p> * * @param box1 * The first box to compare. * @param box2 * The second box to compare. * @return True iff the boxes describe the same region. */ static boolean equals( final Box box1, final Box box2 ) { if ( box1 == null && box2 == null ) return true; if ( box1 == null || box2 == null || !Masks.sameTypesAndDimensions( box1, box2 ) ) return false; for ( int d = 0; d < box1.numDimensions(); d++ ) if ( box1.sideLength( d ) != box2.sideLength( d ) ) return false; return Util.locationsEqual( box1.center(), box2.center() ); } }