# platon1.py

Created by schraf

Created on September 28, 2023

1.3 KB

```from math import *
from turtle import *

def dist(a, b):
return sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2)

def angle(a, b):
return degrees(atan2(b[1] - a[1], b[0] - a[0]))

def point(a):
penup()
goto(a)
pendown()
pensize(4)
goto(position())
pensize(1)

def segment(a, b, coul, dash=True):
color(coul)
r = dist(a, b)
penup()
point(a)
if not(dash):pensize(3)
for i in range(r):
penup() if i % 5 and dash else pendown()
fd(1)
point(b)

def avance(a, b, d):
penup()
goto(a)
fd(d)
pendown()
pensize(4)
goto(position())

def cercle(a, b, r, coul):
color(coul)
avance(a, b, r)
b = position()
segment(a, b, coul)
p = position()
point(p)
circle(int(r))

speed(1)
cercle((0, 0), (50, 0), 50, "grey")
for i in range(6):
cs1, ss1 = 50 * cos(2 * i * pi / 6), 50 * sin(2 * i * pi / 6)
cercle((cs1, ss1), (0, 0),50, "grey")
p = pi/6
pt = []
for i in range(6):
cs1, ss1 = 50 * sqrt(3) * cos(2 * i * pi / 6+p), 50 * sqrt(3) * sin(2 * i * pi / 6+p)
pt.append((cs1,ss1))
cs2, ss2 = 50 * cos(2 * i * pi / 6), 50 * sin(2 * i * pi / 6)
cercle((cs1, ss1), (cs2, ss2),50, "grey")
for i in range(6):
segment(pt[i], pt[(i+1)%6],'red',False)
for i in range(3):
segment(pt[2*i], (0,0),'red',False)

hideturtle()```