How Can You Calculate the Area of a Polygon Using Coordinates?

It's a bit more involved than just multiplying numbers, but it's a very useful tool to have. If you haven't encountered it before, I suggest you look it up. It's also called a determinant, and it's a very useful tool in 3D geometry and physics.
  • #1
cavalieregi
41
0
I have been given various corners which are x and y coordinates for a shape. The coordinates are listed in a vector e.g. xpoints = [x1, x2, x3, …, xn, x1] and ypoints = [y1, y2, y3, …, yn, y1] so that corner 1 would be (x1,y2) and corner n would be (xn, yn). I have listed the first point last so that I can calculate the distance between each point in the shape when using the distance equation. These distances added up will give the perimeter. These points could be anything. The lines made between each point are straight. I was wondering is there a way where I could calculate the total area roughly. I don’t think I could integrate it as I don’t have a function for the shape. I was thinking maybe since all of the lines are straight maybe triangles could be used? Note this is for a programming assignment but is there a mathematical method anyone could think of which I could use to approach this. The picture shows examples of possible areas. Also note the points can be negative to. Also is there any way some could think of only calculating the shaded area. See picture for reference. It include possible shapes.

View attachment 2163
 

Attachments

  • Capture.JPG
    Capture.JPG
    60 KB · Views: 81
Mathematics news on Phys.org
  • #2
cavalieregi said:
I have been given various corners which are x and y coordinates for a shape. The coordinates are listed in a vector e.g. xpoints = [x1, x2, x3, …, xn, x1] and ypoints = [y1, y2, y3, …, yn, y1] so that corner 1 would be (x1,y2) and corner n would be (xn, yn). I have listed the first point last so that I can calculate the distance between each point in the shape when using the distance equation. These distances added up will give the perimeter. These points could be anything. The lines made between each point are straight. I was wondering is there a way where I could calculate the total area roughly. I don’t think I could integrate it as I don’t have a function for the shape. I was thinking maybe since all of the lines are straight maybe triangles could be used? Note this is for a programming assignment but is there a mathematical method anyone could think of which I could use to approach this. The picture shows examples of possible areas. Also note the points can be negative to. Also is there any way some could think of only calculating the shaded area. See picture for reference. It include possible shapes.

Hi cavalieregi! Welcome to MHB! :)

Yes. There is a formula to calculate the area.

We can divide the area in a series of triangles.
Suppose $\mathbf p_i$ is the vector pointing to point i, which has coordinates (xi,yi).

Then the first triangle is between $\mathbf p_1$ , $\mathbf p_2$ and $\mathbf p_3$. The second triangle is between $\mathbf p_1$, $\mathbf p_3$ and $\mathbf p_4$, and so on. That is, all triangles have $\mathbf p_1$ as a common point.

The formula is:
$$\text{Area} = \frac 1 2 \left| \sum_{k=2}^{n-1} (\mathbf p_k - \mathbf p_1) \times (\mathbf p_{k+1} - \mathbf p_1)\right|$$

The operator $\times$ indicates the cross product between vectors.
In this case the cross product between the 2 vectors (a,b) and (c,d) can be represented as (ad - bc).

Calculating it like this, means that a hole such as you have, will indeed not be counted.
More specifically, a shape that is oriented counterclockwise is counted positive, while a shape that is oriented clockwise is counted negative.
Taking the absolute value of the result ensures you get a positive area.
 
  • #3
Thanks for that could you please give me an example with a small intersecting polygon. I don't know how I would apply this formula to any area. Thanks.
 
  • #4
cavalieregi said:
Thanks for that could you please give me an example with a small intersecting polygon. I don't know how I would apply this formula to any area. Thanks.

Let's start with a simple polygon.
Say ((1,1), (2,1), (2,2), (1,2)), which is a square of size 1, which is oriented counterclockwise (aka positive).

Btw, I forgot a factor 1/2, which I've added to my original post just now.

The (new) formula says that:
\begin{aligned}\text{Area}
&= \frac 1 2 \left|\ \Big((2,1) - (1,1)\Big) \times \Big((2,2) - (1,1)\Big) + \Big((2,2) - (1,1)\Big) \times \Big((1,2) - (1,1)\Big)\ \right| \\
&= \frac 1 2 \left|\ (1,0) \times (1,1) + (1,1) \times (0,1)\ \right| \\
&= \frac 1 2 \left|\ (1\cdot 1 - 0 \cdot 1) + (1 \cdot 1 - 1 \cdot 0)\ \right| \\
&= 1\end{aligned}

Note that the symbol $\times$ in this context denotes the so called cross product of vectors as opposed to normal multiplication.
 
  • #5


I would suggest using the shoelace formula to calculate the area of the shape given the coordinates of its corners. This formula works for any shape, regardless of its complexity, as long as the corners are listed in a specific order. This would be a more accurate method than using triangles, as it takes into account the exact coordinates of each corner. Additionally, if you only want to calculate the shaded area, you can subtract the area of any non-shaded regions from the total area calculated using the shoelace formula. This method would also work for shapes with negative coordinates. Another approach could be to use the Monte Carlo method, where you randomly generate points within the shape and calculate the ratio of points within the shaded area to the total number of points generated. This would give you an estimate of the shaded area. However, this method may not be as accurate as the shoelace formula. Overall, it would be helpful to have a function or equation for the shape, but it is not necessary to use the shoelace formula or the Monte Carlo method.
 

FAQ: How Can You Calculate the Area of a Polygon Using Coordinates?

What is Advanced Area Formulation?

Advanced Area Formulation (AAF) is a scientific method used to calculate the area of irregular shapes or surfaces. It takes into account multiple variables, such as curvature and slope, to provide a more accurate measurement of an area.

How is AAF different from traditional area formulas?

Traditional area formulas, such as those for circles or rectangles, assume that the shape is a perfect geometric figure. AAF, on the other hand, considers the complexities of real-world surfaces and takes into account their unique characteristics to provide a more precise measurement.

What types of surfaces can AAF be applied to?

AFF can be applied to any surface, whether it is smooth or rough, curved or flat. It is particularly useful for irregular surfaces, such as those found in nature or in 3D printing, where traditional area formulas may not be accurate enough.

What are the benefits of using AAF?

The main benefit of using AAF is the increased accuracy in calculating area. This can be especially useful in fields such as engineering, architecture, and environmental studies, where precise measurements are crucial. Additionally, AAF allows for a more detailed understanding of a surface's characteristics and can help identify areas of concern or improvement.

How is AAF calculated?

AAF involves breaking down a surface into smaller, more manageable sections and using mathematical algorithms to calculate the area of each section. These values are then combined to provide a final measurement. The specific method of calculation may vary depending on the type of surface being measured.

Back
Top