-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_plots.py
More file actions
171 lines (147 loc) · 6.48 KB
/
generate_plots.py
File metadata and controls
171 lines (147 loc) · 6.48 KB
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/usr/bin/env python3
"""
Script to generate example slackline plots for different configurations.
"""
import sys
sys.path.insert(0, '/home/user/slackline')
from src.api import Constraints, Rig
import matplotlib.pyplot as plt
import matplotlib
matplotlib.use('Agg') # Non-interactive backend
def generate_plot_1():
"""25m slackline with 80kg person in the middle"""
print("Generating Plot 1: 25m slackline with 80kg person at center...")
constraints = Constraints(gap_length=25, anchor_tension=2000)
constraints.add_slackliner(position=12.5, mass=80)
rig = constraints.rig()
plt.figure(figsize=(12, 10))
plt.subplot(221)
plt.plot(rig.x, rig.y, 'b-', linewidth=2)
plt.axvline(x=12.5, color='r', linestyle='--', alpha=0.7, label='80kg')
plt.title("Curve - 25m Line", fontsize=14, fontweight='bold')
plt.xlabel("Horizontal Distance (m)", fontsize=11)
plt.ylabel("Vertical Drop (m)", fontsize=11)
plt.legend()
plt.grid(True, alpha=0.3)
plt.subplot(222)
plt.plot(rig.x, rig.n, label="Natural Length", linewidth=2)
plt.plot(rig.x, rig.l, label="Arc Length", linewidth=2)
plt.axvline(x=12.5, color='r', linestyle='--', alpha=0.5)
plt.title("Natural and Arc Lengths", fontsize=14, fontweight='bold')
plt.xlabel("Horizontal Distance (m)", fontsize=11)
plt.ylabel("Length (m)", fontsize=11)
plt.legend()
plt.grid(True, alpha=0.3)
plt.subplot(223)
plt.plot(rig.x, rig.T, 'r-', linewidth=2)
plt.axvline(x=12.5, color='r', linestyle='--', alpha=0.5)
plt.title("Tension Distribution", fontsize=14, fontweight='bold')
plt.xlabel("Horizontal Distance (m)", fontsize=11)
plt.ylabel("Tension (N)", fontsize=11)
plt.grid(True, alpha=0.3)
plt.subplot(224)
plt.plot(rig.x, rig.A, 'g-', linewidth=2)
plt.axvline(x=12.5, color='r', linestyle='--', alpha=0.5)
plt.title("Angle from Horizontal", fontsize=14, fontweight='bold')
plt.xlabel("Horizontal Distance (m)", fontsize=11)
plt.ylabel("Angle (degrees)", fontsize=11)
plt.grid(True, alpha=0.3)
plt.tight_layout()
plt.savefig('/home/user/slackline/plot1_25m.png', dpi=150, bbox_inches='tight')
plt.close()
print(" ✓ Saved as plot1_25m.png")
def generate_plot_2():
"""100m slackline with two people"""
print("Generating Plot 2: 100m slackline with two people...")
constraints = Constraints(gap_length=100, anchor_tension=3000)
constraints.add_slackliner(position=30, mass=70)
constraints.add_slackliner(position=70, mass=80)
rig = constraints.rig()
plt.figure(figsize=(12, 10))
plt.subplot(221)
plt.plot(rig.x, rig.y, 'b-', linewidth=2)
plt.axvline(x=30, color='r', linestyle='--', alpha=0.7, label='70kg')
plt.axvline(x=70, color='orange', linestyle='--', alpha=0.7, label='80kg')
plt.title("Curve - 100m Line", fontsize=14, fontweight='bold')
plt.xlabel("Horizontal Distance (m)", fontsize=11)
plt.ylabel("Vertical Drop (m)", fontsize=11)
plt.legend()
plt.grid(True, alpha=0.3)
plt.subplot(222)
plt.plot(rig.x, rig.n, label="Natural Length", linewidth=2)
plt.plot(rig.x, rig.l, label="Arc Length", linewidth=2)
plt.axvline(x=30, color='r', linestyle='--', alpha=0.5)
plt.axvline(x=70, color='orange', linestyle='--', alpha=0.5)
plt.title("Natural and Arc Lengths", fontsize=14, fontweight='bold')
plt.xlabel("Horizontal Distance (m)", fontsize=11)
plt.ylabel("Length (m)", fontsize=11)
plt.legend()
plt.grid(True, alpha=0.3)
plt.subplot(223)
plt.plot(rig.x, rig.T, 'r-', linewidth=2)
plt.axvline(x=30, color='r', linestyle='--', alpha=0.5)
plt.axvline(x=70, color='orange', linestyle='--', alpha=0.5)
plt.title("Tension Distribution", fontsize=14, fontweight='bold')
plt.xlabel("Horizontal Distance (m)", fontsize=11)
plt.ylabel("Tension (N)", fontsize=11)
plt.grid(True, alpha=0.3)
plt.subplot(224)
plt.plot(rig.x, rig.A, 'g-', linewidth=2)
plt.axvline(x=30, color='r', linestyle='--', alpha=0.5)
plt.axvline(x=70, color='orange', linestyle='--', alpha=0.5)
plt.title("Angle from Horizontal", fontsize=14, fontweight='bold')
plt.xlabel("Horizontal Distance (m)", fontsize=11)
plt.ylabel("Angle (degrees)", fontsize=11)
plt.grid(True, alpha=0.3)
plt.tight_layout()
plt.savefig('/home/user/slackline/plot2_100m.png', dpi=150, bbox_inches='tight')
plt.close()
print(" ✓ Saved as plot2_100m.png")
def generate_plot_3():
"""500m slackline with someone 100m out"""
print("Generating Plot 3: 500m slackline with person at 100m...")
constraints = Constraints(gap_length=500, anchor_tension=8000)
constraints.add_slackliner(position=100, mass=75)
rig = constraints.rig()
plt.figure(figsize=(12, 10))
plt.subplot(221)
plt.plot(rig.x, rig.y, 'b-', linewidth=2)
plt.axvline(x=100, color='r', linestyle='--', alpha=0.7, label='75kg')
plt.title("Curve - 500m Line", fontsize=14, fontweight='bold')
plt.xlabel("Horizontal Distance (m)", fontsize=11)
plt.ylabel("Vertical Drop (m)", fontsize=11)
plt.legend()
plt.grid(True, alpha=0.3)
plt.subplot(222)
plt.plot(rig.x, rig.n, label="Natural Length", linewidth=2)
plt.plot(rig.x, rig.l, label="Arc Length", linewidth=2)
plt.axvline(x=100, color='r', linestyle='--', alpha=0.5)
plt.title("Natural and Arc Lengths", fontsize=14, fontweight='bold')
plt.xlabel("Horizontal Distance (m)", fontsize=11)
plt.ylabel("Length (m)", fontsize=11)
plt.legend()
plt.grid(True, alpha=0.3)
plt.subplot(223)
plt.plot(rig.x, rig.T, 'r-', linewidth=2)
plt.axvline(x=100, color='r', linestyle='--', alpha=0.5)
plt.title("Tension Distribution", fontsize=14, fontweight='bold')
plt.xlabel("Horizontal Distance (m)", fontsize=11)
plt.ylabel("Tension (N)", fontsize=11)
plt.grid(True, alpha=0.3)
plt.subplot(224)
plt.plot(rig.x, rig.A, 'g-', linewidth=2)
plt.axvline(x=100, color='r', linestyle='--', alpha=0.5)
plt.title("Angle from Horizontal", fontsize=14, fontweight='bold')
plt.xlabel("Horizontal Distance (m)", fontsize=11)
plt.ylabel("Angle (degrees)", fontsize=11)
plt.grid(True, alpha=0.3)
plt.tight_layout()
plt.savefig('/home/user/slackline/plot3_500m.png', dpi=150, bbox_inches='tight')
plt.close()
print(" ✓ Saved as plot3_500m.png")
if __name__ == "__main__":
print("\n=== Generating Slackline Plots ===\n")
generate_plot_1()
generate_plot_2()
generate_plot_3()
print("\n=== All plots generated successfully! ===\n")