NavyDevilDoc commited on
Commit
4b8f4a2
·
verified ·
1 Parent(s): 2c0e901

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +67 -9
src/streamlit_app.py CHANGED
@@ -65,27 +65,85 @@ def create_animated_unit_circle(angle_degrees, show_special_angles=True):
65
  hoverinfo='skip'
66
  ))
67
 
68
- # Fixed special angles display
69
  if show_special_angles:
70
- # Major special angles
71
- major_angles = [0, 30, 45, 60, 90, 120, 135, 150, 180, 210, 225, 240, 270, 300, 315, 330]
72
- special_x = [np.cos(radians(a)) for a in major_angles]
73
- special_y = [np.sin(radians(a)) for a in major_angles]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
 
75
- # Single trace for all special points with labels
76
  fig.add_trace(go.Scatter(
77
  x=special_x,
78
  y=special_y,
79
  mode='markers+text',
80
  marker=dict(size=6, color='gray', opacity=0.8),
81
- text=[f'{a}°' for a in major_angles],
82
  textposition="top center",
83
- textfont=dict(size=8),
84
  showlegend=False,
85
  name='Special Angles',
86
  hovertemplate='%{text}<extra></extra>'
87
  ))
88
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  # Current point
90
  fig.add_trace(go.Scatter(
91
  x=[x_point], y=[y_point],
@@ -117,7 +175,7 @@ def create_animated_unit_circle(angle_degrees, show_special_angles=True):
117
 
118
  # Optimized layout
119
  fig.update_layout(
120
- title=f'Unit Circle at {angle_degrees}°',
121
  xaxis=dict(
122
  range=[-1.2, 1.2],
123
  scaleanchor="y",
 
65
  hoverinfo='skip'
66
  ))
67
 
68
+ # Enhanced special angles display with radians
69
  if show_special_angles:
70
+ # Major special angles with their radian equivalents
71
+ special_angles_data = [
72
+ (0, "0°\n(0)"),
73
+ (30, "30°\n(π/6)"),
74
+ (45, "45°\n(π/4)"),
75
+ (60, "60°\n(π/3)"),
76
+ (90, "90°\n(π/2)"),
77
+ (120, "120°\n(2π/3)"),
78
+ (135, "135°\n(3π/4)"),
79
+ (150, "150°\n(5π/6)"),
80
+ (180, "180°\n(π)"),
81
+ (210, "210°\n(7π/6)"),
82
+ (225, "225°\n(5π/4)"),
83
+ (240, "240°\n(4π/3)"),
84
+ (270, "270°\n(3π/2)"),
85
+ (300, "300°\n(5π/3)"),
86
+ (315, "315°\n(7π/4)"),
87
+ (330, "330°\n(11π/6)")
88
+ ]
89
+
90
+ special_x = [np.cos(radians(angle)) for angle, _ in special_angles_data]
91
+ special_y = [np.sin(radians(angle)) for angle, _ in special_angles_data]
92
+ special_labels = [label for _, label in special_angles_data]
93
 
94
+ # Single trace for all special points with degree and radian labels
95
  fig.add_trace(go.Scatter(
96
  x=special_x,
97
  y=special_y,
98
  mode='markers+text',
99
  marker=dict(size=6, color='gray', opacity=0.8),
100
+ text=special_labels,
101
  textposition="top center",
102
+ textfont=dict(size=7),
103
  showlegend=False,
104
  name='Special Angles',
105
  hovertemplate='%{text}<extra></extra>'
106
  ))
107
 
108
+ # Add arc to show the angle sweep from x-axis to current position
109
+ if angle_degrees > 0:
110
+ # Create arc from 0 to current angle
111
+ arc_angles = np.linspace(0, angle_rad, max(10, int(angle_degrees/10)))
112
+ arc_radius = 0.3 # Smaller radius for the arc
113
+ arc_x = arc_radius * np.cos(arc_angles)
114
+ arc_y = arc_radius * np.sin(arc_angles)
115
+
116
+ fig.add_trace(go.Scatter(
117
+ x=arc_x,
118
+ y=arc_y,
119
+ mode='lines',
120
+ line=dict(color='orange', width=3),
121
+ name=f'Angle Arc ({angle_degrees}°)',
122
+ showlegend=False,
123
+ hoverinfo='skip'
124
+ ))
125
+
126
+ # Add arrow at the end of the arc to show direction
127
+ if len(arc_x) > 1:
128
+ # Arrow direction
129
+ dx = arc_x[-1] - arc_x[-2]
130
+ dy = arc_y[-1] - arc_y[-2]
131
+ fig.add_annotation(
132
+ x=arc_x[-1],
133
+ y=arc_y[-1],
134
+ ax=arc_x[-1] - dx*5,
135
+ ay=arc_y[-1] - dy*5,
136
+ xref="x",
137
+ yref="y",
138
+ axref="x",
139
+ ayref="y",
140
+ arrowhead=2,
141
+ arrowsize=1.5,
142
+ arrowwidth=2,
143
+ arrowcolor="orange",
144
+ showarrow=True
145
+ )
146
+
147
  # Current point
148
  fig.add_trace(go.Scatter(
149
  x=[x_point], y=[y_point],
 
175
 
176
  # Optimized layout
177
  fig.update_layout(
178
+ title=f'Unit Circle at {angle_degrees}° ({angle_rad:.3f} rad)',
179
  xaxis=dict(
180
  range=[-1.2, 1.2],
181
  scaleanchor="y",