# Wolfram Function Repository

Instant-use add-on functions for the Wolfram Language

Function Repository Resource:

Compute the signed area of a polygon

Contributed by:
Ed Pegg Jr and Jan Mangaldan

ResourceFunction["SignedArea"][ computes the signed area of a polygon built out of |

Typically, the signed area of counterclockwise oriented points is positive, while the area for clockwise oriented points is negative.

Often in computer graphics, an outer polygon has counterclockwise points, but any interior hole has clockwise points. The area of the polygon with holes is thus the sum of the signed areas.

ResourceFunction["SignedArea"][Polygon[*pts*]] is equivalent to ResourceFunction["SignedArea"][*pts*].

Calculate the signed area of a square:

In[1]:= |

Out[1]= |

Calculate the area of a set of points making a simple polygon:

In[2]:= |

Out[3]= |

Show the counterclockwise nature of the original points:

In[4]:= |

Out[4]= |

Rotating the points does not change the signed area:

In[5]:= |

Out[5]= |

Reversing the order of the points reverses the sign of the area:

In[6]:= |

Out[6]= |

Swapping the coordinates also makes the signed area negative:

In[7]:= |

Out[7]= |

Find the signed area of a Polygon:

In[8]:= |

Out[8]= |

Find the signed area of a regular polygon:

In[9]:= |

Out[9]= |

Create ten simple random polygons:

In[10]:= |

Calculate the signed areas:

In[11]:= |

Out[11]= |

Use the Area function instead. Note the increased time:

In[12]:= |

Out[12]= |

Use SignedArea to find the winding numbers:

In[13]:= |

Out[13]= |

Polygons from RandomPolygon have a positive signed area:

In[14]:= |

Out[14]= |

Run a timing test between SignedArea and Area:

In[15]:= |

In[16]:= |

Out[16]= |

In[17]:= |

Out[17]= |

Wolfram Language 13.0 (December 2021) or above

- 1.0.0 – 01 September 2023

This work is licensed under a Creative Commons Attribution 4.0 International License