import matplotlib.pyplot as plt
import numpy as np
u=np.linspace(0,4*np.pi,100)
v=np.linspace(-2,2,50)
U,V=np.meshgrid(u,v)
a=0.5
X=V*np.cos(U)
Y=V*np.sin(U)
Z=a*U
fig=plt.figure(figsize=(6,6))
ax=fig.add_subplot(111,projection='3d')
ax.plot_surface(X,Y,Z,cmap='plasma',alpha=0.8,edgecolor='k')
ax.set_title('3D Circular Arc Pattern')
ax.set_xlabel('X axis')
ax.set_ylabel('Y axis')
ax.set_zlabel('Z axis')
ax.set_box_aspect([1,1,1])
plt.tight_layout()
plt.show()
#source code --> clcoding.com
Code Explanation:
1. Imports and Setup
import numpy as np
import matplotlib.pyplot as plt
numpy is used for numerical operations and creating
coordinate grids.
u = np.linspace(0, 4 * np.pi, 100) # Angular parameter (rotation)
v = np.linspace(-2, 2, 50) # Radial parameter (radius from
center)
U, V = np.meshgrid(u, v)
u spans from 0 to 4ฯ — this means the surface will
make 2 full twists (since one full twist is 2ฯ).
a = 0.5 #
Twist rate or height per unit angle
X = V * np.cos(U)
Y = V * np.sin(U)
Z = a * U
These are the parametric equations for a helicoid:
fig = plt.figure(figsize=(10, 8))
ax = fig.add_subplot(111, projection='3d')
Creates a 3D figure and axis.
ax.plot_surface(X, Y, Z, cmap='plasma', alpha=0.8, edgecolor='k')
plot_surface() draws the helicoid.
ax.set_title('3D Circular Arc (Helicoid Surface)')
ax.set_xlabel('X axis')
ax.set_ylabel('Y axis')
ax.set_zlabel('Z axis')
Labels the axes and gives the chart a title.
ax.set_box_aspect([1,1,1]) # Ensures all axes are equally scaled
plt.tight_layout()
plt.show()
Ensures the plot isn't distorted and then renders it
on screen.


0 Comments:
Post a Comment