-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
46 lines (37 loc) · 1 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# import libraries
import numpy as np
import quadtreemap
import sys
WIDTH = 640
HEIGHT = WIDTH
maxlevel = 2
Point = quadtreemap.Point
boundbox = quadtreemap.Rectangle(0, 0, WIDTH, HEIGHT)
map = quadtreemap.QuadTree(boundbox, maxlevel)
tapp = quadtreemap.Tree(WIDTH, HEIGHT)
done = False
while not done:
deg = np.random.randint(360, size=(500))
ang = (np.pi * deg)/180
x = WIDTH/2 + np.random.randint(100,200)*np.cos(ang)
y = HEIGHT/2 + np.random.randint(100,200)*np.sin(ang)
p = quadtreemap.PointCloud(np.vstack([x,y]).transpose())
map.insert(p)
# print(f"Occupied?: {map.isOccupied(Point(x + 50, y + 50))}")
tapp.draw(map.root)
# tapp.draw_point(p, False)
tapp.update()
done = tapp.eventCheck()
map.print_tree()
xx = 2**maxlevel
yy = 2**maxlevel
print(sys.getsizeof(1)*xx*yy)
print('='*50)
qtree = map.invert()
qtree.print_tree()
tapp = quadtreemap.Tree(WIDTH, HEIGHT)
done = False
while not done:
tapp.draw(qtree.root)
tapp.update()
done = tapp.eventCheck()