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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

212 <strong>Learning</strong> <strong>Processing</strong><br />

13.8<br />

Exercise 13-4: A dancer spins around two full rotations. How many degrees did the dancer<br />

rotate? How many radians?<br />

Trigonometry<br />

Degrees: _____________________ Radians: _____________________<br />

Sohcah<strong>to</strong>a. Strangely enough, this seemingly nonsense word, sohcah<strong>to</strong>a , is the foundation for a lot of<br />

computer graphics work. Any time you need <strong>to</strong> calculate an angle, determine the distance between<br />

points, deal with circles, arcs, lines, and so on, you will fi nd that a basic understanding of trigonometry is<br />

essential.<br />

Trigonometry is the study of the relationships between the sides and angles of triangles and sohcah<strong>to</strong>a<br />

is a mnemonic device for remembering the defi nitions of the trigonometric functions, sine, cosine, and<br />

tangent. See Figure 13.8 .<br />

• soh : sine � opposite/hypotenuse<br />

• cah : cosine � adjacent/hypotenuse<br />

• <strong>to</strong>a : tangent � opposite/adjacent<br />

hypotenuse<br />

angle<br />

adjacent<br />

fi g. 13.8<br />

opposite<br />

right angle � 90° � π/2 radians<br />

Any time we display a shape in <strong>Processing</strong> , we have <strong>to</strong> specify a pixel location, given as x and y coordinates.<br />

Th ese coordinates are known as Cartesian coordinates, named for the French mathematician René<br />

Descartes who developed the ideas behind Cartesian space.<br />

Another useful coordinate system, known as polar coordinates , describes a point in space as an angle of<br />

rotation around the origin and a radius from the origin. We can’t use polar coordinates as arguments <strong>to</strong><br />

a function in <strong>Processing</strong> . However, the trigonometric formulas allow us <strong>to</strong> convert those coordinates<br />

<strong>to</strong> Cartesian, which can then be used <strong>to</strong> draw a shape. See Figure 13.9 .

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

Saved successfully!

Ooh no, something went wrong!