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

  • Thread starter Thread starter cavalieregi
  • Start date Start date
  • Tags Tags
    advanced Area
cavalieregi
Messages
41
Reaction score
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: 108
Mathematics news on Phys.org
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.
 
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.
 
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.
 
Insights auto threads is broken atm, so I'm manually creating these for new Insight articles. In Dirac’s Principles of Quantum Mechanics published in 1930 he introduced a “convenient notation” he referred to as a “delta function” which he treated as a continuum analog to the discrete Kronecker delta. The Kronecker delta is simply the indexed components of the identity operator in matrix algebra Source: https://www.physicsforums.com/insights/what-exactly-is-diracs-delta-function/ by...
Fermat's Last Theorem has long been one of the most famous mathematical problems, and is now one of the most famous theorems. It simply states that the equation $$ a^n+b^n=c^n $$ has no solutions with positive integers if ##n>2.## It was named after Pierre de Fermat (1607-1665). The problem itself stems from the book Arithmetica by Diophantus of Alexandria. It gained popularity because Fermat noted in his copy "Cubum autem in duos cubos, aut quadratoquadratum in duos quadratoquadratos, et...
I'm interested to know whether the equation $$1 = 2 - \frac{1}{2 - \frac{1}{2 - \cdots}}$$ is true or not. It can be shown easily that if the continued fraction converges, it cannot converge to anything else than 1. It seems that if the continued fraction converges, the convergence is very slow. The apparent slowness of the convergence makes it difficult to estimate the presence of true convergence numerically. At the moment I don't know whether this converges or not.
Back
Top