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

754<br />

Perimeter of a rectangle<br />

The perimeter of a rectangle equals two times its length plus two times its width:<br />

Area of a circle<br />

The area of a circle equals pi times the radius squared:<br />

Circumference of a circle<br />

The circumference of a circle equals two times pi times its radius:<br />

Area of any non-intersecting polygon<br />

There are times when you need to find the area of a shape (an irregular polygon) that’s<br />

not a rectangle, circle, triangle, or other polygon with a h<strong>and</strong>y area formula. One approach<br />

is to break the shape into smaller triangles <strong>and</strong> sum up their combined areas. However,<br />

there’s an easier solution that works for all non-intersecting polygons, using the shape’s<br />

vertices. This approach, shown in Figure B-3, also lends itself very well to programming.<br />

Figure B-3. Calculating the area of an irregular polygon

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

Saved successfully!

Ooh no, something went wrong!