-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_from_user.py
45 lines (40 loc) · 1.38 KB
/
main_from_user.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
from categorisation import Categorisation
from plotter import Plotter
from file_operation import FileOperations
from geometry import Point
from mini_boundary_rec import MBR
def main():
plotter = Plotter()
file_operations = FileOperations()
mbr = MBR()
categorisation = Categorisation()
category = None
print('read polygon.csv')
polygon = file_operations.read_polygon('polygon.csv')
print('Insert point information')
x, y = file_operations.get_user_input()
test = Point('user input', x, y)
if not mbr.points_in_mbr(test, polygon): # the point is out of MBR
print('outside')
category = 'outside'
else:
boundaries = polygon.get_boundaries()
count_inter = categorisation.ray_intersections(test, boundaries)
if count_inter % 2 == 1:
print('inside')
category = 'inside'
elif count_inter % 2 == 0:
print('outside')
category = 'outside'
for boundary in boundaries:
if categorisation.on_boundary(test, boundary):
print('boundary')
category = 'boundary'
break
print('plot polygon and point')
plotter.add_point(x, y, category)
plotter.add_polygon(polygon.points.x, polygon.points.y)
plotter.ray_plotter(polygon, x, y, kind=category)
plotter.show()
if __name__ == '__main__':
main()