Shakeel1979 commited on
Commit
32e4e2e
·
verified ·
1 Parent(s): a4e5ac5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -11
app.py CHANGED
@@ -104,8 +104,10 @@ def plot_triangle(x1, y1, x2, y2, x3, y3, I_x, I_y, U_x, U_y, G_x, G_y, midpoint
104
  # Plot the triangle vertices
105
  vertices = [(x1, y1), (x2, y2), (x3, y3)]
106
  vertex_labels = [f"Vertex A ({x1:.3f}, {y1:.3f})", f"Vertex B ({x2:.3f}, {y2:.3f})", f"Vertex C ({x3:.3f}, {y3:.3f})"]
 
107
  for i, (vx, vy) in enumerate(vertices):
108
  ax.scatter(vx, vy, color=vertex_color, zorder=3)
 
109
 
110
  # Plot key points with their corresponding colors
111
  key_points = [
@@ -119,11 +121,14 @@ def plot_triangle(x1, y1, x2, y2, x3, y3, I_x, I_y, U_x, U_y, G_x, G_y, midpoint
119
  ax.scatter(x, y, color=color, zorder=4)
120
 
121
  # Plot midpoints of sides
122
- for i, (mx, my) in enumerate(midpoints):
123
- ax.scatter(mx, my, color=midpoint_color, zorder=5)
124
  midpoints_labels = [f"Mid-Point M1 ({(x1 + x2) / 2:.3f}, {(y1 + y2) / 2:.3f})",
125
  f"Mid-Point M2 ({(x2 + x3) / 2:.3f}, {(y2 + y3) / 2:.3f})",
126
  f"Mid-Point M3 ({(x1 + x3) / 2:.3f}, {(y1 + y3) / 2:.3f})"]
 
 
 
 
 
127
 
128
  # Draw the inscribed circle (incircle)
129
  radius_in = calculate_radius_inscribed_circle(a, b, c)
@@ -137,15 +142,15 @@ def plot_triangle(x1, y1, x2, y2, x3, y3, I_x, I_y, U_x, U_y, G_x, G_y, midpoint
137
 
138
  # Add legend
139
  handles = [
140
- plt.Line2D([0], [0], marker='o', color='w', markerfacecolor=vertex_color, markersize=8, label=vertex_labels[0]),
141
- plt.Line2D([0], [0], marker='o', color='w', markerfacecolor=vertex_color, markersize=8, label=vertex_labels[1]),
142
- plt.Line2D([0], [0], marker='o', color='w', markerfacecolor=vertex_color, markersize=8, label=vertex_labels[2]),
143
- plt.Line2D([0], [0], marker='o', color='w', markerfacecolor=midpoint_color, markersize=8, label=midpoints_labels[0]),
144
- plt.Line2D([0], [0], marker='o', color='w', markerfacecolor=midpoint_color, markersize=8, label=midpoints_labels[1]),
145
- plt.Line2D([0], [0], marker='o', color='w', markerfacecolor=midpoint_color, markersize=8, label=midpoints_labels[2]),
146
- plt.Line2D([0], [0], marker='o', color='w', markerfacecolor=incenter_color, markersize=8, label=key_points_labels[0]),
147
- plt.Line2D([0], [0], marker='o', color='w', markerfacecolor=circumcenter_color, markersize=8, label=key_points_labels[1]),
148
- plt.Line2D([0], [0], marker='o', color='w', markerfacecolor=centroid_color, markersize=8, label=key_points_labels[2])
149
  ]
150
  ax.legend(handles=handles, loc='upper left', fontsize=12)
151
 
 
104
  # Plot the triangle vertices
105
  vertices = [(x1, y1), (x2, y2), (x3, y3)]
106
  vertex_labels = [f"Vertex A ({x1:.3f}, {y1:.3f})", f"Vertex B ({x2:.3f}, {y2:.3f})", f"Vertex C ({x3:.3f}, {y3:.3f})"]
107
+ vertex_name = ["A", "B", "C"]
108
  for i, (vx, vy) in enumerate(vertices):
109
  ax.scatter(vx, vy, color=vertex_color, zorder=3)
110
+ ax.text(vx, vy, vertex_name[i], fontsize=10, ha="left", va="bottom", color=vertex_color)
111
 
112
  # Plot key points with their corresponding colors
113
  key_points = [
 
121
  ax.scatter(x, y, color=color, zorder=4)
122
 
123
  # Plot midpoints of sides
 
 
124
  midpoints_labels = [f"Mid-Point M1 ({(x1 + x2) / 2:.3f}, {(y1 + y2) / 2:.3f})",
125
  f"Mid-Point M2 ({(x2 + x3) / 2:.3f}, {(y2 + y3) / 2:.3f})",
126
  f"Mid-Point M3 ({(x1 + x3) / 2:.3f}, {(y1 + y3) / 2:.3f})"]
127
+ midpoint_name = ["M1", "M2", "M3"]
128
+ for i, (mx, my) in enumerate(midpoints):
129
+ ax.scatter(mx, my, color=midpoint_color, zorder=5)
130
+ ax.text(mx, my, midpoint_name[i], fontsize=10, ha="left", va="bottom", color=midpoint_color)
131
+
132
 
133
  # Draw the inscribed circle (incircle)
134
  radius_in = calculate_radius_inscribed_circle(a, b, c)
 
142
 
143
  # Add legend
144
  handles = [
145
+ plt.Line2D([0], [0], marker='o', color='w', markerfacecolor=vertex_color, markersize=6, label=vertex_labels[0]),
146
+ plt.Line2D([0], [0], marker='o', color='w', markerfacecolor=vertex_color, markersize=6, label=vertex_labels[1]),
147
+ plt.Line2D([0], [0], marker='o', color='w', markerfacecolor=vertex_color, markersize=6, label=vertex_labels[2]),
148
+ plt.Line2D([0], [0], marker='o', color='w', markerfacecolor=midpoint_color, markersize=6, label=midpoints_labels[0]),
149
+ plt.Line2D([0], [0], marker='o', color='w', markerfacecolor=midpoint_color, markersize=6, label=midpoints_labels[1]),
150
+ plt.Line2D([0], [0], marker='o', color='w', markerfacecolor=midpoint_color, markersize=6, label=midpoints_labels[2]),
151
+ plt.Line2D([0], [0], marker='o', color='w', markerfacecolor=incenter_color, markersize=6, label=key_points_labels[0]),
152
+ plt.Line2D([0], [0], marker='o', color='w', markerfacecolor=circumcenter_color, markersize=6, label=key_points_labels[1]),
153
+ plt.Line2D([0], [0], marker='o', color='w', markerfacecolor=centroid_color, markersize=6, label=key_points_labels[2])
154
  ]
155
  ax.legend(handles=handles, loc='upper left', fontsize=12)
156