Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Project: Peter's Files
Views: 3893
Visibility: Unlisted (only visible to those who know the link)
Image: ubuntu1804
Kernel: Python 3 (system-wide)
import matplotlib.pyplot as plt import numpy as np from math import sin, cos
# Radii r = [1, 5] # angular velocity w = [2*np.pi, 1] # sample rate (number of samples per time = 1) sample_rate = 20 # time step d_t = 1 / sample_rate # angle steps d_theta = [el * d_t for el in w] # number of time steps total num_steps = 140 # angle locations theta = [[(d_theta[j] * i) % (2 * np.pi) for j in range(2)] for i in range(num_steps)] # generate lines lines = [[[r[j] * cos(loc[j]), r[j] * sin(loc[j])] for j in range(2)] for loc in theta] fig, ax = plt.subplots(figsize=(10,10)) ax.set_aspect('equal') ax.autoscale() # draw circles for i in range(2): t = np.linspace(0, 2 * np.pi,500) x_1 = r[i] * np.cos(t) y_1 = r[i] * np.sin(t) ax.plot(x_1,y_1,'k'); # draw lines for line in lines: line = np.array(line).T ax.plot(*line, 'b', linewidth=.5)
Image in a Jupyter notebook