The SDL Component Suite is an industry leading collection of components supporting scientific and engineering computing. Please visit the SDL Web site for more information....


Unit: SDL_math2
Class: none
Declaration: [1] function PolygonArea (InData: TPDblArray): double;
[2] function PolygonArea (InData: TPDblArray; var ISectCount: integer): double;

The function PolygonArea calculates the area enclosed by the polygon which is specified in the array InData. The sign of the area depends on the order of the polygon points. The area is positive if the numbering of the corners is counterclockwise. Please note that the area of twisted polygons (i.e. if any two edges of the polygon intersect) is not the sum of the sub-polygons but the difference of the areas of the sub-polygons.

Version [2] of PolygonArea detects any intersections of polygon edges (in the case the polygon is twisted) and returns the number of intersections in the variable parameter ISectCount. Please note that version [2] can be quite time-consuming if the number of vertices is high. Thus it is recommended to use version [1] unless you need the number of intersections of a twisted polygon.

Hint: Please note that the points of the polygon have to be stored in the same order as they would be used when drawing the polygon.

Example: This method is used in the following example program (see for downloading the code): convexhull

Last Update: 2023-Feb-06