|
||||
Title: Computing Area of a Polygon Post by Barukh on Jul 4th, 2008, 10:55am Let a simple polygon P be given in the plane. Its vertices V1, …, Vn have coordinates (x1, y1), …, (xn, yn) (any two adjacent vertices form a side of the polygon). Prove that the area of the polygon can be computed by the following formula: where (xn+1, yn+1) = (x1, y1). |
||||
Title: Re: Computing Area of a Polygon Post by towr on Jul 4th, 2008, 1:19pm [hide]You can sum all the areas of trapezoid formed by a linepiece and the x-axis, bearing in might the area can be negative depending on the order of the end points. | Sum (yi + yi+1)/2 * (xi+1 - xi) | 1/2 | Sum yixi+1 + yi+1xi+1 - yixi - yi+1xi | 1/2 | Sum yixi+1 - yi+1xi | (Two terms drop out because they cancel each other when you go round all indices)[/hide] |
||||
Title: Re: Computing Area of a Polygon Post by Grimbal on Jul 5th, 2008, 2:13am [hide]In fact, 1/2 (xi+1yi - xiyi+1) is the oriented surface of the triangle (0,0), (xiyi), (xi+1yi+1) counted positive if the 3 points follow the clockwise direction, negative if not. Adding up all the triangles results in only the inside of the polygon being counted.[/hide] |
||||
Title: Re: Computing Area of a Polygon Post by JohanC on Jul 5th, 2008, 12:42pm Nice. Follow up question: Extend this method to calculate the volume of a polyhedron in 3D ... |
||||
Title: Re: Computing Area of a Polygon Post by towr on Jul 6th, 2008, 7:07am on 07/05/08 at 12:42:16, JohanC wrote:
It's not really as neat as in the 2D case, because you can't get away with a single run around the vertices. |
||||
Title: Re: Computing Area of a Polygon Post by Grimbal on Jul 6th, 2008, 11:46am [hide]Actually, 1/2 (xi+1yi - xiyi+1) is 1/2! det( vi vj ) where the vi and vj define the edges of the polygon. (modulo a sign). Extending to 3D gives 1/3! det( vi vj vk ) where the vi, vj, vk define the triangular faces of the polyhedron (taken all in the same orientation, anticlockwise as seen from the outside). It's even neater than the 2D case. ::)[/hide] |
||||
Title: Re: Computing Area of a Polygon Post by towr on Jul 6th, 2008, 12:29pm Except that faces of a polyhedron needn't be triangles. And you still have the problem of how to run over the indices. |
||||
Title: Re: Computing Area of a Polygon Post by Grimbal on Jul 6th, 2008, 12:42pm Well, if they aren't triangular, just cut them into triangles. And indeed, figuring out over which triplets of vertices to run the sum is more complicated. I just wanted to echo your comment. It is what I do with the triplets that is a simpler expression than the expression we had for the 2D case. |
||||
Title: Re: Computing Area of a Polygon Post by towr on Jul 6th, 2008, 1:07pm on 07/06/08 at 12:42:22, Grimbal wrote:
Quote:
|
||||
Title: Re: Computing Area of a Polygon Post by Grimbal on Jul 6th, 2008, 1:12pm I guess so, but it's a bit difficult to visualize. Especially, what is "clockwise" in 4D? |
||||
Powered by YaBB 1 Gold - SP 1.4! Forum software copyright © 2000-2004 Yet another Bulletin Board |