private void intersectionMatrix ( int [ ] [ ] res , ArrayList < int [ ] > partsx , ArrayList < int [ ] > partsy , int gridsize ) { for ( int x = 0 ; x < gridsize ; x ++ ) { final int [ ] px = partsx . get ( x ) ; final int [ ] rowx = res [ x ] ; for ( int y = 0 ; y < gridsize ; y ++ ) { int [ ] py = partsy . get ( y ) ; rowx [ y ] = intersectionSize ( px , py ) ; } } }
Intersect the two 1d grid decompositions to obtain a 2d matrix .