radioviz.geometry.polygon
Module for polygon geometry operations.
This module provides functions for computing polygon properties such as signed area and normalizing polygon vertex order. It is designed to work with NumPy arrays representing polygon vertices.
Functions
|
Normalize polygon vertices to be ordered counter-clockwise and closed. |
|
Compute the signed area of a polygon using the shoelace formula. |
- radioviz.geometry.polygon.normalize_polygon_ccw(vertices: ndarray) ndarray[source]
Normalize polygon vertices to be ordered counter-clockwise and closed.
This function ensures that polygon vertices are ordered in counter-clockwise direction and that the polygon is closed (first and last vertices are identical).
- Parameters:
vertices (numpy.ndarray) – Array of polygon vertices with shape (N, 2)
- Returns:
Vertices ordered CCW and closed
- Return type:
numpy.ndarray
- Raises:
ValueError – if vertices array does not have the correct shape
- radioviz.geometry.polygon.polygon_signed_area(vertices: ndarray) float[source]
Compute the signed area of a polygon using the shoelace formula.
This function calculates the signed area of a polygon defined by its vertices. The sign indicates the orientation of the polygon: positive for counter-clockwise ordering, negative for clockwise ordering.
- Parameters:
vertices (numpy.ndarray) – Array of polygon vertices with shape (N, 2)
- Returns:
Signed area of the polygon
- Return type:
float
- Raises:
ValueError – if vertices array does not have the correct shape