1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| from mpl_toolkits import mplot3d import numpy as np import matplotlib.pyplot as plt import matplotlib matplotlib.rc('xtick', labelsize=8) matplotlib.rc('ytick', labelsize=8)
def drawLissajous3D(r=2*np.pi, n=500, A=1, B=1, C=1, a=1, b=1, c=2, delta=1.75, epsilon=1.75):
t = np.linspace(0, r, n)
x = A * np.sin(a*t) y = B * np.sin(b*t + delta) z = C * np.sin(c*t + epsilon)
plt.figure(figsize=(8,6)) ax = plt.axes(projection='3d')
ax.plot3D(x, y, z, '-', linewidth=6) ax.set_xlabel('$x = A sin(at)$', fontsize=12) ax.set_ylabel('$y = B sin(bt + \delta)$', fontsize=12) ax.set_zlabel('$z = C sin(ct + \epsilon)$', fontsize=12) plt.title("Lissajous 3D Curve", fontsize=12) ax.view_init(2, 60) plt.show()
drawLissajous3D()
|