
Area of a PolygonGiven: a polygon defined by points (x_{1}, y_{1}) through (x_{n}, y_{n}). The polygon is composed of lines between adjacent vertices, and (x_{1}, y_{1}) is adjacent to (x_{n}, y_{n}). What is the area of the polygon in terms of the coordinates of the vertices? 
The problem is best attacked by dividing the polygon into triangles. There are several ways to determine the area of a triangle, but more importantly, a triangle only has three vertices, so a general formula for the area of the triangle can't be too complicated.
I'm going to present a solution here that does not presuppose a knowledge of vector operations. If you're comfortable with vector operations, then you should probably skip ahead to the vector solution.
Since the location of the triangle doesn't matter, we can always pick one vertex to be at the origin, simply by taking our coordinates to be (0, 0), (x_{1}  x_{0}), and (x_{2}  x_{0}). Therefore, we only need to consider the case where x_{0} = 0. Also, we can always place the leftmost vertex at the origin, so we only need to consider x_{1} ≥ 0 and x_{2} ≥ 0.
It's also convenient to choose which vertex to label x_{1}, and which to label x_{2}. The choice that we make is that the line from the origin to (x_{2}, y_{2}) lies above the line from the origin to x_{1}, y_{1}. This simplifies the derivation of our formula and also the final result.
There are only a few possibilities to consider. An easy one to describe and to visualize is the case where y_{1} < 0 and y_{2} > 0. The area of the triangle can be found easily by dividing it in two along the xaxis. Then the area of each half is simply the onehalf the base times the height, where the base is the xintercept of the line between (x_{1}, y_{1}) and (x_{2}, y_{2}). Designating this xintercept as x_{b}, we get
(1)  x_{b} _{} 


_{} 



Using this value of x_{b}, we find that the area of the triangle is
(2)  A =  1 2 
x_{b} (y_{2} – y_{1}) =  1 2 
(x_{1} y_{2} – x_{1} y_{2}) 
It's straightforward to determine that Equation (2) still applies for the other cases when y_{1} and y_{2} are on the same side of the xaxis, or when either y_{1} or y_{2} are equal to zero. There's a nagging little problem, though—clearly Equation (2) can give a negative value for the area. How do we get out of this dilemma? Well, we took care of it when we required that the line from the origin to (x_{2}, y_{2}) lies above the line from the origin to (x_{1}, y_{1}).
Now that we recognize that switching x_{1} and x_{2} results in a negative area, we're ready to consider the general formula for the area of a triangle where one vertex is at the origin. The area is given by Equation (2), as long as the line from the origin to (x_{2}, y_{2}) lies counterclockwise relative to the line from the origin to (x_{1}, y_{1}).
The magnitude of a vector is another term for the length of the vector. If we identify the line from the origin to the point (x_{1}, y_{1}) as a vector, then the magnitude of that vector is the length √(x_{1}^{2} + y_{1}^{2}).
The vector cross product is a very useful tool for attacking this problem. You can look at my vector operations page for an overview, but we are only interested in a special case. The cross product of two vectors is a vector perpendicular to the two vectors and the magnitude of the cross product is the product of the magnitudes of the original vectors times the sine of the angle between them. This means that the magnitude of the cross product is twice the area of the subtended triangle. The direction of the cross product is defined by the righthand rule. My favorite way to visualize this relationship is to curl the fingers of my right hand. If the direction from the first vector to the second vector is in the direction that my fingers are pointing, then my thumb points in the direction of the cross product.
If the original vectors are in the (x, y) plane, then the cross product is in the ± z direction. If the second vector is counterclockwise with respect to the first, then the cross product is in the + z direction.
The cross product has a simple formula in Cartesian coordinates. (Cartesian coordinates are just the familar x, y, z coordinates.)
(3)  (x_{1}, y_{1}, z_{1}) × (x_{2}, y_{2}, z_{2}) = (y_{1}z_{2} – y_{2}z_{1}, z_{1}x_{2} – z_{2}x_{1}, x_{1}y_{2} – x_{2}y_{1}) 
If the original vectors are in the (x, y) plane, then
(4)  (x_{1}, y_{1}, 0) × (x_{2}, y_{2}, 0) = (0, 0, x_{1}y_{2} – x_{2}y_{1}) 
Any polygon can be divided into triangles in all sorts of different ways. The trick is to figure out a way to do it that can be generalized. The problem is that a general polygon may look a bit odd. An approach that works well for a regular octagon might not work as well for the outline of a bold letter T. We'll just ignore that problem for now. (It turns out that the problem will magically evaporate later.) If we only consider convex polygons, then we can divide the polygon into triangles by picking a vertex and drawing a line from that vertex to each of the other vertices. Alternatively, we can pick a point inside the polygon and draw lines from that point to each of the vertices. The latter is more general without being more difficult, so we'll consider that case.
Let the origin be inside the polygon and divide the polygon into triangles by drawing lines from the origin to each vertex. Number the vertices in the counterclockwise direction x_{1}, x_{2}, . . . , x_{n}. Let A_{1} be the area of triangle from the origin to (x_{1}, y_{1}), then (x_{2}, y_{2}) and back to the origin, and similarly for A_{2}, . . . , A_{n}.
We have a simple formula for each of these triangles using Equation (2). A very nice result, and we are done! But what about polygons with strange shapes? Do we have to divide them up into convex polygons then pick a point inside each one? No we don't. In fact, this formula works for polygons where the origin is not inside of the polygon and for polygons with very strange shapes. To see why, consider the case where the origin is outside of the polygon.
When the origin was inside the polygon, then going counterclockwise around the polygon was the same as going counterclockwise around the origin. But when the origin is outside of the polygon, then going counterclockwise around the polygon is going counterclockwise around the origin for the far side of the polygon, but it is going clockwise around the origin for the near side of the polygon. When we simply apply our formula to the vertices labeled counterclockwise around the polygon, we get positive areas for the far side of the polygon, but we get negative areas for the near side of the polygon. This is exactly what we need, and subtracting out the triangles to the near side from the triangles to the far side leaves only the area inside the polygon.
If you want a closed formula, then
(5)  1 2 

(x_{i}, y_{i}) × (x_{i+1}, y_{i+1}) , 
where the points are labeled counterclockwise; we define (x_{n+1}, y_{n+1}) = (x_{1}, y_{1}); and we consider the twodimensional cross product to be the zcomponent of the threedimensional cross product.
I have solved this problem, but it is considerably more involved than the planar case. I have not written the solution in HTML format, but I'll present an outline of the method here.
The area of a triangle on the sphere is equal to the sum of the angles of the triangle minus pi. For example, consider one eighth of a sphere with one vertex at the north pole and the other two vertices on the equator, separated by 90 degrees of longitude. Each angle is 90 degrees or π / 2. The area of the triangle is 3π / 2 – π = π / 2, which is one eighth of the area of the sphere.
You can develop a closed formula for the area of a triangle with one vertex at θ = 0, but you have to resolve the clockwise/counterclockwise issue a little differently, because you can always have an angle greater than 180 degrees at θ = 0. This is because two points determine two lines on a sphere—one that goes the short way and one that goes the long way. Anyway, after you resolve all of these issues, then you get a formula that is superficially similar to Equation (5), which finds the area of the polygon, but it requires you to know how many times the path went around the pole.
Send all responses to .
Thanks,