Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Compute the signed area of a polygon
ResourceFunction["SignedArea"][pts] computes the signed area of a polygon built out of pts in the given order. |
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
This work is licensed under a Creative Commons Attribution 4.0 International License