06.01.2013 Views

Learning Processing: A Beginner's Guide to Programming Images ...

Learning Processing: A Beginner's Guide to Programming Images ...

Learning Processing: A Beginner's Guide to Programming Images ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

13.6<br />

Perlin Noise<br />

Mathematics 207<br />

One of the qualities of a good random number genera<strong>to</strong>r is that the numbers produced appear <strong>to</strong> have no<br />

relationship. If they exhibit no discernible pattern, they are considered random .<br />

In programming behaviors that have an organic, almost lifelife quality, a little bit of randomness is a good<br />

thing. However, we do not want <strong>to</strong>o much randomness. Th is is the approach taken by Ken Perlin, who<br />

developed a function in the early 1980’s entitled “ Perlin noise ” that produces a naturally ordered (i.e.,<br />

“ smooth ” ) sequence of pseudo-random numbers. It was originally designed <strong>to</strong> create procedural textures,<br />

for which Ken Perlin won an Academy Award for Technical Achievement. Perlin noise can be used <strong>to</strong><br />

generate a variety of interesting eff ects including clouds, landscapes, marble textures, and so on.<br />

Figure 13.3 shows two graphs,—a graph of Perlin noise over time (the x -axis represents time; note how<br />

the curve is smooth) compared <strong>to</strong> a graph of pure random numbers over time. (Visit this book’s web site<br />

for the code that generated these graphs.)<br />

fi g. 13.3<br />

}<br />

void draw() {<br />

background(0);<br />

float r = random(1);<br />

____________________________________________________<br />

____________________________________________________<br />

____________________________________________________<br />

____________________________________________________<br />

____________________________________________________<br />

____________________________________________________<br />

ellipse(width/2,y,16,16);<br />

Perlin Noise Random

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!