1 package cz.cuni.amis.pogamut.defcon.utils.quadtree;
2
3
4
5
6
7
8
9 public class WidthLimitedQuadTreePostorderIterator extends
10 DepthLimitedQuadTreePostorderIterator {
11
12 public WidthLimitedQuadTreePostorderIterator(QuadTree tree, double minWidth) {
13 super(tree, getDepth(minWidth, tree.getRoot().getSize()));
14 }
15
16 private final static int getDepth(double minWidth, double size) {
17
18 if (minWidth > size) {
19 throw new IllegalArgumentException(
20 "minWidth argument " + minWidth +
21 " cannot be > tree size " + size + ". ");
22 }
23
24 double tmp = size / minWidth;
25
26 tmp = Math.ceil(Math.log(tmp) / Math.log(2));
27
28 return (int) tmp;
29 }
30
31 }