Introduction to Game Programming with C++ (Wordware Game Developers Library)

3.6 Area and Perimeter

The perimeter of a polygon is the sum of the lengths of its sides. In other words, if you took a walk along the edges of a polygon so that you walked completely around the polygon and ended up back where you started, the distance you walked would be the perimeter.

The measure of the amount of space inside the edges of any polygon is called its area, and the area of any polygon is related to the length of its sides. There are numerous ways to calculate the area of different polygons, and often the method can be to decompose the polygon into triangles, calculate the area, and then add them all up. For this reason I demonstrate how to calculate the area of a square and a triangle.

Категории