import numpy as np
import matplotlib.pyplot as plt
r = 1
theta = np.linspace(0, 4 * np.pi, 1000)
x_cycloid = r * (theta - np.sin(theta))
y_cycloid = r * (1 - np.cos(theta))
R = 3
r_epicycloid = 1
x_epicycloid = (R + r_epicycloid) * np.cos(theta) - r_epicycloid * np.cos((R + r_epicycloid) / r_epicycloid * theta)
y_epicycloid = (R + r_epicycloid) * np.sin(theta) - r_epicycloid * np.sin((R + r_epicycloid) / r_epicycloid * theta)
plt.figure(figsize=(10, 5))
plt.subplot(1, 2, 1)
plt.plot(x_cycloid, y_cycloid, color='blue')
plt.title('Cycloid')
plt.axis('equal')
plt.subplot(1, 2, 2)
plt.plot(x_epicycloid, y_epicycloid, color='red')
plt.title('Epicycloid')
plt.axis('equal')
plt.tight_layout()
plt.show()
#source code --> clcoding.com
0 Comments:
Post a Comment