magnet.geometric_utils.shoelace_formula#

magnet.geometric_utils.shoelace_formula(v: ndarray) float#

Compute the area of a 2D polygon.

Computes the signed area of a polygon; the area is positive if the vertices are ordered counter-clockwise, negative if clockwise instead.

Parameters:

v (np.ndarray of float) – array of shape (N, 2), where N is the number of vertices of the polygon, containing the coordinates of its vertices ordered as they are encountered on the perimeter.

Returns:

The computed area.

Return type:

float