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

670<br />

I then took this initial polygon data <strong>and</strong> lathed it around the z-axis, on the xy plane, with<br />

the following expressions:<br />

vertices2[j].x = cos(radians(latheAngle))*vertices[j].x;<br />

vertices2[j].y = sin(radians(latheAngle))*vertices[j].x;<br />

vertices2[j].z = vertices[j].z;<br />

Notice that the equations are basically the original unit circle expressions, where the cos()<br />

function controls the x component of a point, the sin() function controls the y component,<br />

<strong>and</strong> vertices[j].x is the toroid radius value. Instead of a single point, though, I’m<br />

rotating a group of points that just happen to form a polygon on the xz plane.<br />

The rest of the program is stuff I’ve gone over before. One small snippet that might raise<br />

a question, however, is the following:<br />

if (isHelix){<br />

latheAngle+=720.0/segments;<br />

}<br />

I decided to rotate the helix version of the toroid two rotations instead of one, just to better<br />

illustrate the coil effect—that’s why I used 720.0 instead of 360.0. If you want, you can<br />

change that number to see the effect. If you make it higher, you might also want to raise<br />

the 80 segment level maximum in the conditional head if (segments

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

Saved successfully!

Ooh no, something went wrong!