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<br />

Mathematics<br />

Mathematics 201<br />

“ If people do not believe that mathematics is simple, it is only because they do not realize how complicated<br />

life is. ”<br />

—John von Neumann<br />

“ If you were cosine squared, I’d be sine squared, because <strong>to</strong>gether we’d be one. ”<br />

—Anonymous<br />

In this chapter:<br />

– Probability.<br />

– Perlin noise.<br />

– Trigonometry.<br />

– Recursion.<br />

Here we are. Th e fundamentals are fi nished and we are going <strong>to</strong> start looking at some more sophisticated<br />

<strong>to</strong>pics in <strong>Processing</strong> . You may fi nd there is less of a s<strong>to</strong>ry <strong>to</strong> follow from chapter <strong>to</strong> chapter. Nonetheless,<br />

although the concepts do not necessarily build on each other as fl uidly as they did previously, the chapters<br />

are ordered with a step-by-step learning approach in mind.<br />

Everything we do from here on out will still employ the same fl ow structure of setup( ) and draw( ) . We<br />

will continue <strong>to</strong> use functions from the <strong>Processing</strong> library and algorithms made of conditional statements<br />

and loops, and organize sketches with an object-oriented approach in mind. At this point, however, the<br />

descriptions will assume a knowledge of these essential <strong>to</strong>pics and I encourage you <strong>to</strong> return <strong>to</strong> earlier<br />

chapters <strong>to</strong> review as needed.<br />

13.1<br />

Mathematics and <strong>Programming</strong><br />

Did you ever start <strong>to</strong> feel the sweat beading on your forehead the moment your teacher called you up <strong>to</strong><br />

the board <strong>to</strong> write out the solution <strong>to</strong> the latest algebra assignment? Does the mere mention of the word<br />

“ calculus ” cause a trembling sensation in your extremities?<br />

Relax, there is no need <strong>to</strong> be afraid. Th ere is nothing <strong>to</strong> fear, but the fear of mathematics itself. Perhaps at<br />

the beginning of reading this book, you feared computer programming. I certainly hope that, by now, any<br />

terrifi ed sensations associated with code have been replaced with feelings of serenity. Th is chapter aims <strong>to</strong><br />

take a relaxed and friendly approach <strong>to</strong> a few useful <strong>to</strong>pics from mathematics that will help us along the<br />

journey of developing <strong>Processing</strong> sketches.<br />

You know, we have been using math all along.<br />

For example, we have likely had an algebraic expression on almost every single page since learning variables.<br />

x = x + 1;

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

Saved successfully!

Ooh no, something went wrong!