User:Thierry Dugnolle/Python/Double-slit-experiment
Appearance
print("Double slit experiment")
from PIL import Image, ImageDraw
import random
import math
imWidth=800
imHeight=360
particlesNumber=40
particleRadius=1.0
stripesNumber=5
imNumber=300
im = Image.new("1",(imWidth,imHeight),0)
draw = ImageDraw.Draw(im)
for imnum in range(imNumber):
for i in range(particlesNumber):
x = random.random() * imWidth
y = random.random() * imHeight
test=math.sin(x / imWidth * stripesNumber * math.pi + math.pi / 2)
if test*test<random.random():
draw.ellipse([x-particleRadius,y-particleRadius,x+particleRadius,y+particleRadius],1)
im.save("DSE"+str(1000+imnum)+".gif")
print("Good bye")