svoid test_QuadTreeBitMatrix() { // 4*4, one pixel white BitSetMatrix m = new(4, 4); m.set(1, 1); QuadTreeBitMatrix qt = bitMatrixToQuadTree(m); assertTrueVerbose(equal := eqMatrices(m, qt)); assertEqualsVerbose(2, qt.compositeNodeCount()); // turn pixel back to black qt.set(1, 1, false); m.set(1, 1, false); assertTrueVerbose(equal := eqMatrices(m, qt)); print(structure(qt)); qt.set(1, 1, false); print(structure(qt)); assertEqualsVerbose(0, qt.compositeNodeCount()); // all pixels white for y to 4: for x to 4: qt.set(x, y); assertEqualsVerbose(0, qt.compositeNodeCount()); test_QuadTreeBitMatrix_2(); } svoid test_QuadTreeBitMatrix_2() { for (double p = .1; p < 1; p += .1) { new Average nodes; repeat 100 { var matrix = randomBitMatrix(8, 8, p); QuadTreeBitMatrix qt = bitMatrixToQuadTree(matrix); nodes.add(qt.compositeNodeCount()); assertTrue(eqMatrices(matrix, qt)); } printVars(+p, +nodes); } }