import numpy as np
import matplotlib.pyplot as plt
plt.figure(figsize=(5,5),dpi=80)
def F(x0,y0,r,a): #定義遞迴程式
if r <1 :return
x1=x0+0.04*r*np.cos(a) ; y1=y0+0.04*r*np.sin(a)
x2=x1+0.04*r*np.cos(a-pi/90) ; y2=y1+0.04*r*np.sin(a-pi/90)
X=[x0,x1,x2]
Y=[y0,y1,y2]
plt.plot(X,Y,color="green",linewidth=2) #畫圖
F(x1,y1,0.3*r,a+pi*4/9)
F(x2,y2,0.3*r,a-pi*41/90)
F(x2,y2,0.9*r,a-pi/90)
#以下內容為主程式
pi=3.14159 #圓周率
(x0,y0,r,a)=(0,0,90,pi/2) #(基準點之x,y坐標,長度,方向角)
F(0,0,90,pi/2)
plt.show()