一日小海龜聽聞有人能用派生畫『心』︰
How can I draw a heart using Python?
import matplotlib.pyplot as plt import numpy as np t = np.arange(0,2*np.pi, 0.1) x = 16*np.sin(t)**3 y = 13*np.cos(t)-5*np.cos(2*t)-2*np.cos(3*t)-np.cos(4*t) plt.plot(x,y) plt.show()
雖然『折線』之法尚不純熟,仍想嘗試一番︰
up@up-UP-CHT01:~x[n+1] - x[n] \approx 0\frac{y[n+1] - y[n]}{x[n+1] - x[n]}\begin{array}{rcl} x(t)&=&R\left[(1-k)\cos t+lk\cos \frac{1-k}{k}t\right] ,\\[4pt] y(t)&=&R\left[(1-k)\sin t-lk\sin \frac{1-k}{k}t\right] .\\\end{array}Rk=\frac{r}{R}0\le k \le 1l=\frac{\rho}{r}0\le l \le 1$。網路上有一個『Spirograph Art』的網頁,假使讀者有興趣的話,不妨前去看看。