algorithmgeometry

What's a good algorithm for calculating the area of a quadrilateral?


I see there's a good question already for general polygons here. Are there any simpler or more efficient algorithms specific to quadrilaterals?


Solution

  • For a (convex) quadrilateral, it's often faster to just split the quad into two triangles, and compute the area of the two triangles.

    If the quadralateral is not guaranteed convex, the closed polygon approach is still my preference, since it's usually faster than the checks to figure out how to correctly split the quad.


    Edit from Comments:

    As Walt W points out, the two approaches are theoretically identical in terms of performance. The second is more flexible, due to not requiring convex quads, but the first (splitting triangles) is easier to implement as well as understand, so potentially more maintainable.