EarShellSimulation / assets /2d_visualization.png
jithenderchoudary's picture
Create 2d_visualization.png
e39ce8a verified
raw
history blame contribute delete
873 Bytes
def generate_2d_image(height, radius):
try:
theta = np.linspace(0, 2 * np.pi, 100)
x_outer = radius * np.cos(theta)
y_outer = height * np.sin(theta) / max(np.sin(theta))
plt.figure(figsize=(6, 6))
plt.plot(x_outer, y_outer, label="Outer Shell", color="blue")
plt.fill_between(x_outer, y_outer, color="lightblue", alpha=0.5)
plt.axhline(0, color="black", linewidth=0.5, linestyle="--")
plt.axvline(0, color="black", linewidth=0.5, linestyle="--")
plt.title("2D Cross-Section of Ear-Like Bird Shell")
plt.xlabel("Radius (mm)")
plt.ylabel("Height (mm)")
plt.grid()
plt.legend()
plt.savefig("2d_visualization.png")
return "2d_visualization.png"
except Exception as e:
print(f"Error in generating 2D visualization: {e}")
return None