DebasishDhal99 commited on
Commit
66b2203
·
1 Parent(s): cc6e945

Add center and axes in reflective, fix edge case in non-refletive

Browse files
backend/nonreflecting_ray_tracing.py CHANGED
@@ -40,6 +40,7 @@ def nonreflecting_plotter(a = 20, b = 20, r = 15, ray_count = 50, clutter = "No"
40
 
41
  circle = plt.Circle((a, b), r, color='blue', fill=False)
42
  ax.add_artist(circle)
 
43
 
44
  def draw_line(angle, length=max(max_dim, 500), x_0=0, y_0=0):
45
  x_1 = length * mt.cos(angle) + x_0
@@ -85,7 +86,7 @@ def nonreflecting_plotter(a = 20, b = 20, r = 15, ray_count = 50, clutter = "No"
85
  fig.canvas.draw()
86
  image_array = np.array(fig.canvas.renderer.buffer_rgba())
87
  plt.close(fig)
88
- return image_array
89
  # raise ValueError("Circle radius is too large for the given center coordinates.")
90
 
91
  lower_angle = theta_center - delta
@@ -139,4 +140,4 @@ def nonreflecting_plotter(a = 20, b = 20, r = 15, ray_count = 50, clutter = "No"
139
  image_array = np.array(fig.canvas.renderer.buffer_rgba())
140
  plt.close(fig)
141
  hit_ratio = (total_hits / ray_count) * 100
142
- return image_array, f"{hit_ratio:.2f}"
 
40
 
41
  circle = plt.Circle((a, b), r, color='blue', fill=False)
42
  ax.add_artist(circle)
43
+ ax.plot(a, b, 'ro', markersize=5) # Circle center
44
 
45
  def draw_line(angle, length=max(max_dim, 500), x_0=0, y_0=0):
46
  x_1 = length * mt.cos(angle) + x_0
 
86
  fig.canvas.draw()
87
  image_array = np.array(fig.canvas.renderer.buffer_rgba())
88
  plt.close(fig)
89
+ return image_array, 100
90
  # raise ValueError("Circle radius is too large for the given center coordinates.")
91
 
92
  lower_angle = theta_center - delta
 
140
  image_array = np.array(fig.canvas.renderer.buffer_rgba())
141
  plt.close(fig)
142
  hit_ratio = (total_hits / ray_count) * 100
143
+ return image_array, f"{hit_ratio:.5f}"
backend/reflecting_ray_tracing.py CHANGED
@@ -63,7 +63,9 @@ def reflecting_plotter(a = 20, b = 20, r = 15, ray_count = 15, clutter = "No"):
63
  ax.set_aspect('equal', adjustable='box')
64
  ax.set_xlabel('X-axis')
65
  ax.set_ylabel('Y-axis')
66
-
 
 
67
  circle = plt.Circle((a, b), r, color='black', fill=False)
68
  ax.add_artist(circle)
69
  ax.plot(a, b, 'ro', markersize=5)
@@ -158,4 +160,4 @@ def reflecting_plotter(a = 20, b = 20, r = 15, ray_count = 15, clutter = "No"):
158
  plt.close(fig)
159
 
160
  hit_ratio = 100*total_hits / ray_count
161
- return image_array, f"{hit_ratio:.1f}"
 
63
  ax.set_aspect('equal', adjustable='box')
64
  ax.set_xlabel('X-axis')
65
  ax.set_ylabel('Y-axis')
66
+ ax.axhline(0, color='black', lw=1)
67
+ ax.axvline(0, color='black', lw=1)
68
+
69
  circle = plt.Circle((a, b), r, color='black', fill=False)
70
  ax.add_artist(circle)
71
  ax.plot(a, b, 'ro', markersize=5)
 
160
  plt.close(fig)
161
 
162
  hit_ratio = 100*total_hits / ray_count
163
+ return image_array, f"{hit_ratio:.5f}"