Over a million developers have joined DZone.

Sine Wave Interference Patterns

DZone's Guide to

Sine Wave Interference Patterns

Free Resource
A nice visualization from Simon Wittber's recipe

from appuifw import *
import e32, random
from math import *

app.body = c = Canvas()
width, height =  c.size
freq = random.choice([25., 50., 100., 200., 400.])

for y in range(height):
    for x in range(width):
        z1 = sin(x/freq*1.7*pi)
        z2 = sin((x/3+y)/freq*1.5*pi)
        z3 = sin(y/freq*0.1*pi)

        z = abs(z1+z2+z3)*255
        c.point((x,y), (z,z/4,z*4))
c.text((5, height-12), u'Freq = %d' %freq, 0xffffff)

e32.ao_sleep(5)    # wait 5 sec then quit

See a screenshot here.

Opinions expressed by DZone contributors are their own.


Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}