Spaces:
Sleeping
Sleeping
Commit
•
8683ed3
1
Parent(s):
b4f0e09
Trying out the spinner
Browse files- disc_golf_simulator.py +36 -39
disc_golf_simulator.py
CHANGED
@@ -17,6 +17,10 @@ default_roll = 14.7
|
|
17 |
|
18 |
def main():
|
19 |
tab1, tab2 = st.tabs(['Simulator', 'FAQ'])
|
|
|
|
|
|
|
|
|
20 |
with tab1:
|
21 |
disc_names = {
|
22 |
'Innova Wraith': 'dd2',
|
@@ -45,55 +49,48 @@ def main():
|
|
45 |
value=default_pitch,
|
46 |
step=0.1)
|
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 |
-
vb_link = 'https://visitor-badge.glitch.me/badge?page_id=derek-thomas.disc-golf-simulator&left_color=gray&right_color=blue'
|
91 |
-
visitor_badge = f"![Total Visitors]({vb_link})"
|
92 |
-
st.markdown(f"""
|
93 |
-
Thanks for visiting :)
|
94 |
-
|
95 |
-
![Total Visitors]({vb_link})
|
96 |
-
""")
|
97 |
|
98 |
with tab2:
|
99 |
st.markdown("""
|
|
|
17 |
|
18 |
def main():
|
19 |
tab1, tab2 = st.tabs(['Simulator', 'FAQ'])
|
20 |
+
vb_link = 'https://visitor-badge.glitch.me/badge?page_id=derek-thomas.disc-golf-simulator&left_color=gray&right_color=blue'
|
21 |
+
st.sidebar.markdown(f"""
|
22 |
+
![Total Visitors]({vb_link})
|
23 |
+
""")
|
24 |
with tab1:
|
25 |
disc_names = {
|
26 |
'Innova Wraith': 'dd2',
|
|
|
49 |
value=default_pitch,
|
50 |
step=0.1)
|
51 |
|
52 |
+
with st.spinner(text="Calculating Flight Path..."):
|
53 |
+
pos = np.array((0, 0, z0))
|
54 |
+
disc_dict = DiscGolfDisc(disc_name)
|
55 |
|
56 |
+
stl_mesh = get_stl(proj_dir / 'shotshaper' / 'discs' / (disc_name + '.stl'))
|
57 |
+
fig = visualize_disc(stl_mesh, nose=nose, roll=roll)
|
58 |
|
59 |
+
st.markdown("""## Disc Orientation""")
|
60 |
+
st.plotly_chart(fig)
|
61 |
+
st.markdown("""## Flight Path""")
|
62 |
+
shot = disc_dict.shoot(speed=U, omega=omega, pitch=pitch,
|
63 |
+
position=pos, nose_angle=nose, roll_angle=roll)
|
64 |
|
65 |
+
# Plot trajectory
|
66 |
+
x, y, z = shot.position
|
67 |
+
x_new, y_new = -1 * y, x
|
68 |
|
69 |
+
# Reversed x and y to mimic a throw
|
70 |
+
fig = get_plot(x_new, y_new, z)
|
71 |
+
st.plotly_chart(fig, True)
|
72 |
|
73 |
+
st.markdown(
|
74 |
+
f"""
|
75 |
+
**Arrows in Blue** show you where your *s-turn* is.
|
76 |
|
77 |
+
**Arrows in Red** show you your *max height* and *lateral deviance*.
|
78 |
|
79 |
+
Hit Play to watch your animated throw.
|
80 |
|
81 |
+
| Metric | Value |
|
82 |
+
|--------------|--------|
|
83 |
+
| Drift Left | {round(min(x_new), 2)} |
|
84 |
+
| Drift Right | {round(max(x_new), 2)} |
|
85 |
+
| Max Height | {round(max(z), 2)} |
|
86 |
+
| Distance | {round(max(y_new), 2)} |
|
87 |
|
88 |
+
"""
|
89 |
+
)
|
90 |
|
91 |
+
arc, alphas, betas, lifts, drags, moms, rolls = disc_dict.post_process(shot, omega)
|
92 |
+
fig = get_subplots(arc, alphas, lifts, drags, moms, rolls, shot.velocity)
|
93 |
+
st.plotly_chart(fig, True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
|
95 |
with tab2:
|
96 |
st.markdown("""
|