import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
theta=np.linspace(0,20*np.pi,1000)
z=np.linspace(-2,2,1000)
r=z**2+1
x=r*np.sin(theta)
y=r*np.cos(theta)
fig=plt.figure(figsize=(6,8))
ax=fig.add_subplot(111,projection='3d')
ax.plot(x,y,z,color='cyan',linewidth=2)
ax.set_title('Quantum Vortex Pattern',fontsize=18,color='purple')
ax.set_facecolor('black')
fig.patch.set_facecolor('black')
ax.grid(False)
ax.set_xticks([])
ax.set_yticks([])
ax.set_zticks([])
plt.show()
#source code --> clcoding.com
Code Explanation:
1. Import Required Libraries
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
Purpose:
numpy → For mathematical calculations like arrays,
linspace, trigonometric functions.
theta = np.linspace(0, 20 * np.pi, 1000)
z = np.linspace(-2, 2, 1000)
r = z**2 + 1
Explanation:
theta → Controls the angle of the spiral (0 to 20π
means multiple spiral loops).
(As z increases or decreases, radius changes — gives
a vortex or tornado effect).
x = r * np.sin(theta)
y = r * np.cos(theta)
Purpose:
Parametric equations of a spiral in 3D:
fig = plt.figure(figsize=(10, 7))
ax = fig.add_subplot(111, projection='3d')
Explanation:
Create a new figure of size 10x7.
ax.plot(x, y, z, color='cyan', linewidth=2)
Purpose:
Draw the 3D vortex spiral using the x, y, z points.
ax.set_title('Quantum Vortex 3D Pattern',
fontsize=18, color='purple')
ax.set_facecolor('black')
fig.patch.set_facecolor('black')
ax.grid(False)
Purpose:
Add a custom title to the plot.
ax.set_xticks([])
ax.set_yticks([])
ax.set_zticks([])
Purpose:
Remove the axis ticks (numbers) for an aesthetic and
clean design.
plt.show()
Purpose:
Display the final 3D vortex pattern on the screen.
0 Comments:
Post a Comment