-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_bokeh.py
87 lines (51 loc) · 1.65 KB
/
test_bokeh.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
import json
from bokeh.plotting import figure, output_file, show
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.collections import PolyCollection
import matplotlib as mpl
import copy
from importlib import reload
import json
from pprint import pprint as pp
with open('Parser/data_shapes.json') as json_data:
d = json.load(json_data)
json_data.close()
list_of_polys = []
for key, value in d.items():
list_of_polys.append(value)
import Panels
reload(Panels)
A = Panels.panel(list_of_polys[0])
plane = Panels.plane(list_of_polys=list_of_polys)
plane.fix_ref_location(-100, -100)
plane.fix_ref_rotation(np.pi/2)
if False:
fig, ax = plt.subplots()
coll = PolyCollection(plane.current(), edgecolors='black')
ax.add_collection(coll)
for i in range(1,10):
plane.move_forward( 140 )
if i % 2 ==0:
rr = -45 + np.random.random_sample()*90
turn_deg = np.radians(rr)
plane.update_rotation( turn_deg )
coll = PolyCollection(plane.current(), edgecolors='black')
ax.add_collection(coll)
ax.autoscale_view()
ax.set_aspect('equal', 'box')
plt.show()
output_file("patch.html")
p = figure(match_aspect=True)
# add a patch renderer with an alpha an line width
for poly in plane.current():
p.patch(poly[:,0],poly[:,1], alpha=0.5, line_width=2)
for i in range(1,10):
plane.move_forward( 140 )
if i % 2 ==0:
rr = -45 + np.random.random_sample()*90
turn_deg = np.radians(rr)
plane.update_rotation( turn_deg )
for poly in plane.current():
p.patch(poly[:,0],poly[:,1], alpha=0.5, line_width=2)
show(p)