I want to build an AABB tree for a set of primitives that are points in 2d, in python. I found the corresponding library https://aabbtree.readthedocs.io/en/latest/ but the documentation has only one example which I cannot comprehend how is going to help me.
In the example one does give AABB's on themselves.
The process that I am aware of receives a set of primitives (geometric objects like polygons, segments, points, e.t.c) and computes the AABB tree : The root is an AABB sourounding all the primitives, then it has two children (two AABB's inside the root) and so on... So the user is not supposed to know the AABB's already . Expect if we may need to insert the AABB'S in the leaf nodes .
I am genuinely confused by the example in the documentation . I tried to follow the code in git repo that draws the tree : https://github.com/kip-hart/AABBTree/blob/master/plot_incremental.py.
I tried to break the code in def main() in pieces to understand how it works but I am confused. In the resulted tree there are 9 leafs. However , I don't even undestand when the user gave these 9 primitives as input. Maybe it's when we define the #box sets :
# Box sets
box_1 = aabbtree.AABB([(-21, -18), (-21, -18)]) ##leaf !!
box_2 = aabbtree.AABB([(-17, -14), (-21, -18)])
box_3 = aabbtree.AABB([(-16, -13), (-16, -13)])
box_4 = aabbtree.AABB([(-12, -9), (-16, -13)])
But these are only 4.
I also don't get at all how can one find the AABB's in each level of the tree. I see no method get.aabb() or so.
If you can give a concrete example it would help a ton .