tete3d.py

Created by schraf

Created on March 29, 2022

2 KB

Une vidéo est en cours de réalisation pour expliquer comment obtenir des résultats analogues en partant de Geogebra


import turtle
T = turtle
T.speed(0)

PTS = [(-10,-91),(5,-90),(30,-74),(36,-59),(47,-44),(60,-40),(47,-5),(57,21),(54,53),(35,72),(17,84),(1,88),(-13,85),(-42,68),(-48,59),(-53,30),(-50,18),(-50,6),(-54,-4),(-45,-12),(-48,-19),(-43,-21),(-39,-19),(-24,-28),(-36,-25),(-46,-25),(-47,-30),(-38,-30),(-35,-36),(-43,-36),(-44,-43),(-44,-50),(-35,-50),(-39,-54),(-24,-54),(-18,-52),(-25,-50),(-11,-26),(-2,-4),(-29,-7),(-38,-13),(-46,-4),(-35,24),(-43,24),(-45,19),(-49,34),(-32,33),(-6,29),(6,17),(3,-46),(7,-35),(20,-20),(36,17),(25,-24),(19,-35),(-27,19),(-20,66),(4,56),(-5,-48),(13,-84),(35,-9),(-50,-8),(-48,-25)]
HACH = [[48,56,49,47,43,56],[10,9,53,8],[14,15,46,16],[47,57,48,58],[40,42,43,56],[56,40,39,49],[40,41,42,20,19],[21,26,22,25,23,24],[27,30,28,29,24],[17,45,16,46,44],[32,34,33,35,37,36],[37,38,51,52,39,49,53,58,10,11,57,12,14,13],[14,15,57,47,46],[1,36,2,59,50,60,55,3,54,4],[4,54,5,61,6,7],[7,61,8,53,52,54,51,55,50,51,59,36]]

def position(a,b,s,t):
    return t * s[0] * a[0] + (1-t) * s[0] * b[0], t * s[1] * a[1] + (1-t) * s[1] * b[1] - 10

def segments(l,sym=[[1,1]],coul=(0,0,0), taille = 1):
    T.pensize(taille)
    T.color(coul)
    for s in sym:
        for i in range(len(l)):
            T.penup() if i == 0 else T.pendown()
            T.goto(s[0] * PTS[l[i]-1][0],s[1] * PTS[l[i]-1][1] - 10)

def region(data, coul=(0,0,0), taille=1, n=5):
    for i in range(len(data)-2):
        hachure((data[i], data[i+1],data[i+2],coul,taille,[[1,1]]),n)

def hachure(data, n):
    (a,b,c,coul,taille,sym) = data
    T.color(coul)
    T.pensize(taille)
    for s in sym:
        for i in range(n):
            t = i / n
            T.penup()
            x, y = position(PTS[a-1], PTS[b-1], s, t)
            T.goto(x, y)
            T.pendown()
            x, y = position(PTS[a-1], PTS[c-1], s, t)
            T.goto(x, y)    

for r in HACH: region(r,coul=(250,220,230),taille=10,n=3)
for r in HACH: region(r,coul=(235,145,187),taille=4,n=4)
for r in HACH: region(r,coul=(124,22,70),taille=1,n=8)


T.hideturtle()