forked from sbochkar/distributed_coverage_planner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpolygons.py
109 lines (83 loc) · 7.17 KB
/
polygons.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
def gen_poly_and_decomp(poly_id=0):
"""
Hard coded polygons and decompositions
"""
if poly_id == 0:
# A rectangle
P = [[(0.0,0.0),(10.0,0.0),(10.0,1.0),(0.0,1.0)],[]]
cellToSiteMap = {0: (0,0), 1:(0,0), 2:(0,0), 3:(0,0)}
decomposition = [[[(0.0,0.0),(10.0,0.0), (10.0,0.5)],[]], [[(0.0,0.0),(10.0,0.5),(10.0,1.0),(5.0,0.5)],[]], [[(5.0,0.5),(10.0,1.0),(0.0,1.0)],[]], [[(0.0,0.0),(5.0,0.5),(0.0,1.0)],[]]]
elif poly_id == 1:
# A rectangle
P = [[(0.0,0.0),(10.0,0.0),(10.0,1.0),(0.0,1.0)],[]]
cellToSiteMap = {0: (10,0), 1:(10,1), 2:(0,1), 3:(0,0)}
decomposition = [[[(0.0,0.0),(2.5,0.0),(2.5,1.0),(0.0,1.0)],[]], [[(2.5,0.0),(5.0,0.0),(5.0,1.0),(2.5,1.0)],[]], [[(5.0,0.0),(7.5,0.0),(7.5,1.0),(5.0,1.0)],[]], [[(7.5,0.0),(10.0,0.0),(10.0,1.0),(7.5,1.0)],[]]]
elif poly_id == 2:
# A octagon
P = [[(1.0,0.0),(2.0,0.0),(3.0,1.0),(3.0,2.0),(2.0,3.0),(1.0,3.0),(0.0,2.0),(0.0,1.0)],[]]
cellToSiteMap = {0: (1,-1), 1:(2.0,-1), 2:(3,3), 3:(0,3)}
decomposition = [[[(0.8333333333333334,0.16666666666666666),(0.9285714285714286,1.7857142857142854),(1.0,3.0),(0.0,2.0),(0.0,1.0)],[]], [[(0.9285714285714286,1.7857142857142854),(1.6818181818181817,1.8636363636363633),(3.0,2.0),(2.0,3.0),(1.0,3.0)],[]], [[(1.6818181818181817,1.8636363636363633),(0.9285714285714286,1.7857142857142854),(0.8333333333333334, 0.16666666666666666),(1.0,0.0),(2.0,0.0)], []], [[(1.6818181818181817, 1.8636363636363633), (2.0, 0.0), (3.0, 1.0), (3.0, 2.0)], []]]
elif poly_id == 3:
# A complex shape without holes
P = [[(0.0, 0.0),(4.0, 0.0),(4.0, 4.0),(6.0, 4.0),(6.0, 0.0),(10.0, 0.0),(10.0, 6.0),(8.0, 7.0),(7.5, 8.0),(10.0, 7.5),(10.0, 10.0),(0.0, 10.0),(0.0, 5.0),(5.0, 6.0),(5.0, 5.0),(0.0, 4.0)],[]]
cellToSiteMap = {0: (10,0), 1:(10,10), 2:(0,10), 3:(0,0)}
decomposition = [[[(0.0,0.0),(4.0,0.0),(4.0,4.0),(6.0,4.0),(5.0, 5.0),(0.0, 4.0)],[]],
[[(6.0,4.0),(6.0,0.0),(10.0,0.0),(10.0,6.0),(8.0,7.0),(5.0,5.0)],[]],
[[(7.5,8.0),(10.0,7.5),(10.0,10.0),(0.0,10.0),(0.0,5.0),(5.0,6.0)],[]],
[[(5.0,5.0),(8.0,7.0),(7.5,8.0),(5.0,6.0)],[]]]
elif poly_id == 4:
# A more complex shape with one hole
P = [[(0.0,0.0),(6.0,0.0),(6.0,5.0),(4.0,5.0),(4.0,3.0),(5.0,3.0),(5.0,2.0),(3.0,2.0),(3.0,6.0),(7.0,6.0),(7.0,0.0),(10.0,0.0),(10.0,10.0),(0.0,10.0)],[[(4.0,7.0),(3.5,8.0),(4.5,9.0),(6.0,8.0)]]]
cellToSiteMap = {0: (10,0), 1:(10,10), 2:(0,10), 3:(0,0)}
# decomposition = [[[(6.0,0.0),(6.0,5.0),(4.0,5.0),(4.0,3.0),(5.0,3.0),(5.0,2.0)],[]],
# [[(7.0,6.0),(7.0,0.0),(10.0,0.0),(10.0,10.0)],[]],
# [[(7.0,6.0),(10.0,10.0),(0.0,10.0),(3.5,8.0),(4.5,9.0),(6.0,8.0)],[]],
# [[(0.0,0.0),(6.0,0.0),(5.0,2.0),(3.0,2.0),(3.0,6.0),(7.0,6.0),(6.0,8.0),(4.0,7.0),(3.5,8.0),(0.0,10.0)],[]]]
decomposition = [[[(6.0,0.0),(6.0,5.0),(4.0,5.0),(4.0,3.0),(5.0,3.0),(5.0,2.0)],[]],
[[(7.0,6.0),(7.0,0.0),(10.0,0.0),(10.0,10.0),(6.0,8.0),(4.0,7.0)],[]],
[[(6.0,8.0),(10.0,10.0),(0.0,10.0),(3.5,8.0),(4.5,9.0)],[]],
[[(0.0,0.0),(6.0,0.0),(5.0,2.0),(3.0,2.0),(3.0,6.0),(7.0,6.0),(4.0,7.0),(3.5,8.0),(0.0,10.0)],[]]]
elif poly_id == 5:
# A rectangle
P = [[(0.0,0.0),(9.0,0.0),(9.0,1.0),(0.0,1.0)],[]]
cellToSiteMap = {0: (0,0), 1:(0,0), 2:(0,0)}
#decomposition = [[[(0.0,0.0),(3,0.0),(3,1.0),(0.0,1.0)],[]], [[(3,0.0),(6.0,0.0),(6.0,1.0),(3,1.0)],[]], [[(6.0,0.0),(9.0,0.0),(9.0,1.0),(6.0,1.0)],[]],]
decomposition = [[[(0.0,0.0),(1.0,0.0),(1.0,1.0),(0.0,1.0)],[]], [[(1.0,0.0),(6.0,0.0),(6.0,1.0),(1.0,1.0)],[]], [[(6.0,0.0),(9.0,0.0),(9.0,1.0),(6.0,1.0)],[]],]
elif poly_id == 6:
P = [[(0.0,0.0),(10.0,0.0),(10.0,10.0),(0.0,10.0)],[[(7.0,1.0),(7.0,3.0),(8.0,3.0),(8.0,1.0)],[(1.0,4.0),(1.5,4.5),(3.0,5.0),(3.5,4.5),(3.0,3.0),(2.0,3.0)],[(4.0,7.0),(6.0,9.0),(7.0,8.0),(6.0,7.0),(8.0,6.0),(8.5,6.5),(9.0,6.0),(8.0,5.0)]]]
cellToSiteMap = {0: (10,0), 1:(10,10), 2:(0,10), 3:(0,0)}
decomposition = [[[(0.0,0.0),(1.0,4.0),(1.5,4.5),(3.0,5.0),(4.0,7.0),(6.0,9.0),(10.0,10.0),(0.0,10.0)],[]],
[[(0.0,0.0),(7.0,1.0),(7.0,3.0),(8.0,5.0),(4.0,7.0),(3.0,5.0),(3.5,4.5),(3.0,3.0),(2.0,3.0),(1.0,4.0)],[]],
[[(0.0,0.0),(10.0,0.0),(10.0,10.0),(9.0,6.0),(8.0,5.0),(7.0,3.0),(8.0,3.0),(8.0,1.0),(7.0,1.0)],[]],
[[(10.0,10.0),(6.0,9.0),(7.0,8.0),(6.0,7.0),(8.0,6.0),(8.5,6.5),(9.0,6.0)],[]]]
elif poly_id == 7:
P = [[(0.0,0.0),(4.0,0.0),(4.0,5.0),(2.0,5.0),(2.0,6.0),(5.0,6.0),(5.0,0.0),(10.0,0.0),(10.0,4.0),(7.0,4.0),(7.0,5.0),(10.0,5.0),(10.0,10.0),(0.0,10.0)],[[(7.0,7.0),(7.0,9.0),(8.0,9.0),(8.0,7.0)],[(3.0,7.0),(2.0,8.0),(3.0,9.0),(6.0,8.0)]]]
cellToSiteMap = {0: (10,0), 1:(10,10), 2:(0,10), 3:(0,0)}
decomposition = [[[(0.0,0.0),(4.0,0.0),(4.0,5.0),(2.0,5.0),(0.0,5.0)],[]],
[[(0.0,10.0),(0.0,5.0),(2.0,5.0),(2.0,6.0),(3.0,6.0),(3.0,7.0),(2.0,8.0),(3.0,9.0),(3.0,10.0)],[]],
[[(10.0,7.0),(10.0,10.0),(3.0,10.0),(3.0,9.0),(6.0,8.0),(7.0,9.0),(8.0,9.0),(8.0,7.0),],[]],
[[(10.0,0.0),(10.0,4.0),(7.0,4.0),(7.0,5.0),(10.0,5.0),(10.0,7.0),(8.0,7.0),(7.0,7.0),(7.0,9.0),(6.0,8.0),(3.0,7.0),(3.0,6.0),(5.0,6.0),(5.0,0.0)],[]]]
# New combined holes
elif poly_id == 8:
# A more complex shape with one hole
P = [[(0.0,0.0),(6.0,0.0),(6.0,5.0),(4.0,5.0),(4.0,3.0),(5.0,3.0),(5.0,2.0),(3.0,2.0),(3.0,6.0),(3.9,6.0),(3.9,7.0),(3.5,8.0),(4.5,9.0),(6.0,8.0),(4.1,7.0),(4.1,6.0),(7.0,6.0),(7.0,0.0),(10.0,0.0),(10.0,10.0),(0.0,10.0)],[]]
cellToSiteMap = {0: (10,0), 1:(10,10), 2:(0,10), 3:(0,0)}
decomposition = [[[(6.0,0.0),(6.0,5.0),(4.0,5.0),(4.0,3.0),(5.0,3.0),(5.0,2.0)],[]],
[[(7.0,6.0),(7.0,0.0),(10.0,0.0),(10.0,10.0),(6.0,8.0),(4.1,7.0),(4.1,6.0)],[]],
[[(6.0,8.0),(10.0,10.0),(0.0,10.0),(3.5,8.0),(4.5,9.0)],[]],
[[(0.0,0.0),(6.0,0.0),(5.0,2.0),(3.0,2.0),(3.0,6.0),(3.9,6.0),(3.9,7.0),(3.5,8.0),(0.0,10.0)],[]]]
elif poly_id == 9:
P = [[(0.0,0.0),(7.0,0.0),(7.0,3.0),(7.4,3.0),(7.9,5.0),(4.1,7.0),(3.1,5.0),(3.5,4.5),(3.0,3.0),(2.0,3.0),(1.0,4.0),(1.5,4.5),(2.9,5.0),(3.9,7.0),(6.0,9.0),(7.0,8.0),(6.0,7.0),(8.0,6.0),(8.5,6.5),(9.0,6.0),(8.1,5.0),(7.6,3.0),(8.0,3.0),(8.0,0.0),(10.0,0.0),(10.0,10.0),(0.0,10.0)],[]]
cellToSiteMap = {0: (10,0), 1:(10,10), 2:(0,10), 3:(0,0)}
decomposition = [[[(0.0,0.0),(1.0,4.0),(1.5,4.5),(2.9,5.0),(3.9,7.0),(6.0,9.0),(10.0,10.0),(0.0,10.0)],[]],
[[(0.0,0.0),(7.0,0.0),(7.0,3.0),(7.4,3.0),(7.9,5.0),(4.1,7.0),(3.1,5.0),(3.5,4.5),(3.0,3.0),(2.0,3.0),(1.0,4.0)],[]],
[[(8.0,0.0),(10.0,0.0),(10.0,6.0),(9.0,6.0),(8.1,5.0),(7.6,3.0),(8.0,3.0)],[]],
[[(10.0,10.0),(6.0,9.0),(7.0,8.0),(6.0,7.0),(8.0,6.0),(8.5,6.5),(9.0,6.0),(10.0,6.0)],[]]]
elif poly_id == 10:
P = [[(0.0,0.0),(4.0,0.0),(4.0,5.0),(2.0,5.0),(2.0,6.0),(5.0,6.0),(5.0,0.0),(10.0,0.0),(10.0,4.0),(7.0,4.0),(7.0,9.0),(8.0,9.0),(8.0,5.0),(10.0,5.0),(10.0,10.0),(3.1,10.0),(3.1,9.0),(6.0,8.0),(3.0,7.0),(2.0,8.0),(2.9,9.0),(2.9,10.0),(0.0,10.0)],[]]
cellToSiteMap = {0: (10,0), 1:(10,10), 2:(0,10), 3:(0,0)}
decomposition = [[[(0.0,0.0),(4.0,0.0),(4.0,5.0),(2.0,5.0),(0.0,5.0)],[]],
[[(0.0,10.0),(0.0,5.0),(2.0,5.0),(2.0,6.0),(3.0,6.0),(3.0,7.0),(2.0,8.0),(2.9,9.0),(2.9,10.0)],[]],
[[(10.0,5.0),(10.0,10.0),(3.1,10.0),(3.1,9.0),(6.0,8.0),(7.0,9.0),(8.0,9.0),(8.0,5.0)],[]],
[[(10.0,0.0),(10.0,4.0),(7.0,4.0),(7.0,9.0),(6.0,8.0),(3.0,7.0),(3.0,6.0),(5.0,6.0),(5.0,0.0)],[]]]
return P, cellToSiteMap, decomposition