def triangoloequadrati(x,y,x1,y1):
# primo cateto
lato = math.sqrt((x-x1)**2+(y-y1)**2)
if lato > dettaglio:
bx = (x-x1)*(math.cos(alpha))**2
by = (y-y1)*(math.cos(alpha))**2
(nx,ny) = ruota(bx,by,0,0,-1)
ax = nx*math.tan(alpha)
ay = ny*math.tan(alpha)
x2 = x1+bx+ax
y2 = y1+by+ay
(q2x, q2y) = ruota(x2,y2,x,y,1)
(q3x, q3y) = ruota(x,y,q2x,q2y,1)
plt.plot([x,x1,x2,x],[y,y1,y2,y],'k-')
plt.plot([x,q2x],[y,q2y],'b-')
plt.plot([q2x,q3x],[q2y,q3y],'b-')
plt.plot([q3x,x1],[q3y,y1],'b-')
# secondo cateto
(r2x, r2y) = ruota(x2,y2,x1,y1,-1)
(r3x, r3y) = ruota(x1,y1,r2x,r2y,-1)
plt.plot([x1,r2x],[y1,r2y],'b-')
plt.plot([r2x,r3x],[r2y,r3y],'b-')
plt.plot([r3x,x2],[r3y,y2],'b-')
# chiamata ricorsiva
triangoloequadrati(r3x,r3y,r2x,r2y)
triangoloequadrati(q2x,q2y,q3x,q3y)
else:
return 1