Sign Area of Irregular Polygon


The polygons can be regular or irregular. For example,

polygon Sign Area of Irregular Polygon algorithms beginner c # geometry implementation math programming languages tricks

Regular or Irregular Polygons

The following idea is the easiest way to compute its area (signed) for any given simple 2-D polygons, even for concave ones.

1. Compute the value tex_09b393f2e2975ad12fa6bc52ea3fe143 Sign Area of Irregular Polygon algorithms beginner c # geometry implementation math programming languages tricks for every edge segment of the polygon.

2. Sum them up:

The C# code shown following clearly illustrates the idea.

1
2
3
4
5
6
7
8
9
10
11
        
public static double area(double[] x, double[] y, int n)
{
    double area = 0.0;
    for (int i = 1; i < n; i++)
    {
        area += (x[i] - x[i - 1]) * (y[i] + y[i - 1]) * 0.5;
    }
    area += (x[0] - x[n - 1]) * (y[0] + y[n - 1]) * 0.5;
    return area;
}
        
public static double area(double[] x, double[] y, int n)
{
    double area = 0.0;
    for (int i = 1; i < n; i++)
    {
        area += (x[i] - x[i - 1]) * (y[i] + y[i - 1]) * 0.5;
    }
    area += (x[0] - x[n - 1]) * (y[0] + y[n - 1]) * 0.5;
    return area;
}

Let’s try to compute the following polygon.

polygon2 Sign Area of Irregular Polygon algorithms beginner c # geometry implementation math programming languages tricks

Example Concave Polygon, Algorithm to compute its signed area

We loop each edge and compute the sum of the difference of width multiply the average height.

The compute process is like following.

polygon3 Sign Area of Irregular Polygon algorithms beginner c # geometry implementation math programming languages tricks

Table, process to compute the signed area of a polygon

For more information, you might visit this page.

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
347 words
Last Post: Codeforces: 236A. Boy or Girl ?
Next Post: Algorithm Complexity

The Permanent URL is: Sign Area of Irregular Polygon

Leave a Reply