Article Preview
Buy Now
| Print: | |
| PDF: |
Feature
Polygon area
Determining the area of a polygon
Issue: 3.5 (May/June 2005)
Author: Thomas Reed
Author Bio: Thomas Reed has been programming as a hobbyist for more than 20 years, and fell in love with the Mac in 1984.
Article Description: No description available.
Article Length (in bytes): 8,224
Starting Page Number: 34
RBD Number: 3515
Resource File(s):
3515.sit Updated: Wednesday, May 18, 2005 at 11:40 AM
3515.zip Updated: Wednesday, May 18, 2005 at 11:40 AM
Related Link(s): None
Known Limitations: None
Excerpt of article text...
Last issue, we talked about how to determine whether a point lies within an arbitrary polygon. To continue on the polygon theme, and thanks to a recent question on the REALbasic Network Users Group mailing list that got me thinking, this time I'd like to discuss finding the area of a polygon. We all know that the formula for the area of a square is width times height. A right triangle would be half of that (taking the sides that meet at the right angle as the width and height). A circle is pi times the radius squared. Okay, those are easy! But what about an arbitrary polygon with any number of straight sides, connected at any angles?
At first glance, this seems like it would be an extremely complex task. Visually, we can break down a polygon into triangles, rectangles, and other regular shapes and get an estimate, or sometimes even a precise value, for the area. Consider the example in Figure 1. A human might visually "cut" the polygon into two triangles, rearrange them into a square, and announce that the area is 100. A computer, however, lacking our intuitive powers, cannot perform this task as easily. So how do we write a program to determine the area of this shape?
...End of Excerpt. Please purchase the magazine to read the full article.
Article copyrighted by REALbasic Developer magazine. All rights reserved.
|










