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.

Here’s how the process works: pick a point on the polygon <strong>and</strong> begin moving in a counterclockwise<br />

fashion around the shape. Assuming the first point you choose is (x start , y start )<br />

<strong>and</strong> the last point before you close the shape is (x n , y n ), you multiply the start x value with<br />

the next vertex’s y value <strong>and</strong> subtract that same vertex’s x value multiplied by the start y<br />

value. You continue this process all the way around the shape. Obviously, the last point will<br />

be the first point (x start , y start ), since you’re dealing with a closed shape. Finally, you take half<br />

of the entire value to get the area. Here’s the process in a generalized equation form:<br />

Trigonometry<br />

Please note that if you happen to do the rotation in the wrong direction,<br />

<strong>and</strong> move in a clockwise fashion around the polygon, you’ll get<br />

the same area, but as a negative value.<br />

The trig functions are central to graphics programming. However, if you’re anything like<br />

me, you probably have a hazy memory of how <strong>and</strong> why they are used. Perhaps you<br />

remember the mnemonic device soh-cah-toa, used to remember the relationships<br />

between the trig functions <strong>and</strong> a right triangle (illustrated in Figure B-4).<br />

Figure B-4. The relationship of trig functions to a right triangle<br />

MATH REFERENCE<br />

755<br />

B

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

Saved successfully!

Ooh no, something went wrong!