vue3dv2.py

Created by schraf

Created on August 21, 2022

699 Bytes

Autre version ici


from kandinsky import set_pixel
from math import *
from random import random

for n in range(223):
  for m in range(320):
    x,y,z,u,v = 0,0,-.8,(m-159.9)/160,(.8*n-85.9)/111
    w = 1/sqrt(u*u+v*v+1)
    u *= w
    v *= w
    i = copysign(1, u)
    k = 1
    while k !=0:
      k,e,f = 0, x-i,y-i
      p = u*e+v*f+w*z
      d = p*p-e*e-f*f-z*z+1
      if d > 0:
        t = -p-sqrt(d)
        if t > 0:
          k = 1
          x += t*u
          y += t*v
          z += t*w
          e,f,p = x-i,y-i,1.3*(u*e+v*f+w*z)
          u -= p*e
          v -= p*f
          w -= p*z
          i = -i
    cc = max(0,min(255,20*int(12*w-7*v-5*u+random())))
    set_pixel(m, 222-n, (cc,)*3)

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 <a href="https://www.numworks.com/legal/cookies-policy/">cookies policy</a>.