04.04.2013 Views

Processing: Creative Coding and Computational Art

Processing: Creative Coding and Computational Art

Processing: Creative Coding and Computational Art

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.

PROCESSING: CREATIVE CODING AND COMPUTATIONAL ART<br />

130<br />

When you run the sketches, notice how the box actually accelerates. If you plotted the<br />

equations that generated this motion, you’d get approximations of the acceleration curve.<br />

Later in the book you’ll experiment with both constant <strong>and</strong> accelerated motion more, as<br />

well as add cool features like gravity, collisions, <strong>and</strong> springs. One final point about working<br />

with these types of equations is the potential of generating extremely large or small numbers<br />

very quickly—approaching positive or negative infinity. Actually, you don’t have to<br />

worry about reaching infinity, forgetting about the obvious paradoxical aspect, as<br />

<strong>Processing</strong> will give you an error way before that. As an exercise in futility, but perhaps also<br />

some small interest, try running the following sketch, which simply begins with the value 1<br />

<strong>and</strong> continues doubling it for 100 steps (if smoke begins pouring out of your computer,<br />

I’m sure it’s just a sad coincidence):<br />

double n = 1.0;<br />

for (int i=1; i

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

Saved successfully!

Ooh no, something went wrong!