# 8/04/2025
# Approximation des arcs de cercles avec des segments.
from random import*
import time
def arc1(x,y,n):
LP=[]
for k in range(n+1):
O=Point(x,y,is_visible=False)
A=Point(x+0.5,y,is_visible=False)
P=Rotate(A,k/n*3.14/2,O)
P.is_visible=False
LP.append(P)
for k in range(n):
Segment(LP[k],LP[k+1])
def arc2(x,y,n):
LP=[]
for k in range(n+1):
O=Point(x+1,y+1,is_visible=False)
A=Point(x+0.5,y+1,is_visible=False)
P=Rotate(A,k/n*3.14/2,O)
P.is_visible=False
LP.append(P)
for k in range(n):
Segment(LP[k],LP[k+1])
def arc3(x,y,n):
LP=[]
for k in range(n+1):
O=Point(x,y+1,is_visible=False)
A=Point(x,y+0.5,is_visible=False)
P=Rotate(A,k/n*3.14/2,O)
P.is_visible=False
LP.append(P)
for k in range(n):
Segment(LP[k],LP[k+1])
def arc4(x,y,n):
LP=[]
for k in range(n+1):
O=Point(x+1,y,is_visible=False)
A=Point(x+1,y+0.5,is_visible=False)
P=Rotate(A,k/n*3.14/2,O)
P.is_visible=False
LP.append(P)
for k in range(n):
Segment(LP[k],LP[k+1])
def tuile1(x,y,n):
arc1(x,y,n)
arc2(x,y,n)
def tuile2(x,y,n):
arc3(x,y,n)
arc4(x,y,n)
def dessin(dim,n):
for y in range(dim):
for x in range(dim):
a = randint(0,1)
time.sleep(0.001)
if a==0:
tuile1(x,y,n)
else:
tuile2(x,y,n)
# Exécution:
dim = 5 # dimension du motif généré. Les tuiles sont placées
# dans un carré de côté de longueur dim.
n = 10 # nombre de points définissant le pseudo arc de cercle.
# Pour une valeur de n supérieur à 10, la génération du motif
# commence à devenir très lente.
dessin(dim,n)