# points3d.py

Created by schraf

Created on April 08, 2023

1.32 KB

Vidéo et explications en cours de réalisation

```import turtle
from math import cos,sin,exp,pi,atan
from kandinsky import fill_rect

t = turtle
t.speed(0)
t.hideturtle()
t.pensize(1)
t.color(255,255,0)

fill_rect(0,0,320,222,(0,0,0))

def cosin(theta):
a = theta * pi / 180
return cos(a), sin(a)

def pitchx(p):
c,s = cosin(p)
return [[1,0,0,0],[0,c,-s,0],[0,s,c,0],[0,0,0,1]]

c,s = cosin(h)
return [[c,0,-s,0],[0,1,0,0],[s,0,c,0],[0,0,0,1]]

def rollz(r):
c,s = cosin(r)
return [[c,-s,0,0],[s,c,0,0],[0,0,1,0],[0,0,0,1]]

def trans(x,y,z):
return [[1,0,0,-x],[0,1,0,-y],[0,0,1,-z],[0,0,0,1]]

def mult(m1,m2):
return [[sum(a*b for a,b in zip(ligne,col)) for col in zip(*m2)] for ligne in m1]

def ViewM(x,y,z,p,h,r):

def ModelM(x,y,z,p,h,r):

camera = ViewM(0,0,0,130,0,0)
modele = ModelM(0,0,0,180,0,0)
matrix = mult(camera,modele)

for r in range(1,50):
d = 20 * exp(r/10)
p = 180
for k in range(p):
x,y,z,w = d * cos(k * 2 * pi / p), d * sin(k * 2 * pi /p), \
-200+10*r,  1
v = mult(matrix,[[x],[y],[z],[1]])
t.penup()
t.goto(v[0][0],v[1][0])
t.pendown()
t.goto(v[0][0],v[1][0])

t.hideturtle()```