penrose3.py

Created by schraf

Created on August 13, 2022

692 Bytes

Version en couleurs ici


from turtle import *
from math import pi, sin, cos

def co(angle) : return cos(angle * pi / 180)
def si(angle) : return sin(angle * pi / 180)

def penrose(n):
    pensize(2)
    penup()
    delta = 360 / n
    alpha, beta = 180 - delta, delta / 2
    a, b = 70 * si(2 * beta), 10
    goto(-a / 2, 110 - a)
    pendown()    
    for _ in range(n):
        for (t,r) in ((360-delta,b),(delta,a+2*b+2*b*co(alpha)),
                      (delta,a+2*b+4*b*co(alpha)),(beta,2*b*si(alpha/2)),
                      (180-beta,a+2*b+2*b*co(alpha)),(360-delta,a+b),
                      (180,a),(delta,0)):
            rt(t);fd(r)

n = int(input('Nb cotes ? '))
penrose(n)
hideturtle()

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.