maths.shoelace_area =================== .. py:module:: maths.shoelace_area .. autoapi-nested-parse:: Shoelace formula (Gauss's area formula) for polygon area. The function accepts an iterable of (x, y) pairs and returns the polygon area as a non-negative float. References: - https://en.wikipedia.org/wiki/Shoelace_formula Attributes ---------- .. autoapisummary:: maths.shoelace_area.example Functions --------- .. autoapisummary:: maths.shoelace_area.shoelace_area Module Contents --------------- .. py:function:: shoelace_area(points: collections.abc.Iterable[tuple[float, float]]) -> float Compute the area of a simple polygon using the shoelace formula. Parameters ---------- points: Iterable of (x, y) coordinate pairs. Points may be ints or floats. The polygon is assumed closed (the function will wrap the last point to the first). Returns ------- float Non-negative area of the polygon. Raises ------ ValueError If fewer than 3 points are provided. TypeError If points are not pairs of numbers. Examples >>> shoelace_area([(0, 0), (4, 0), (0, 3)]) 6.0 >>> shoelace_area([(0, 0), (1, 0), (1, 1), (0, 1)]) 1.0 >>> shoelace_area(list(reversed([(0, 0), (2, 0), (2, 2), (0, 2)]))) 4.0 >>> shoelace_area([(0, 0), (2, 0), (2, 2), (0, 2)]) 4.0 .. py:data:: example :value: [(0, 0), (4, 0), (0, 3)]