raygeo.geo.algo.analysis
Path analysis utilities for inspecting and cleaning geometry data.
Provides functions for removing duplicate points from point sequences, extracting subpath vertices, computing subpath/geometry area, and determining path winding order.
Functions
get_area()
get_area(geometry: geo.Geometry) -> float
Compute the total unsigned area enclosed by the geometry.
Sums all subpaths (outer + inner). Returns 0 for empty or open geometry.
| Parameter | Type | Description |
|---|---|---|
geometry | geo.Geometry | Geometry to compute area from. |
| Returns | float | Total unsigned area. |
| Complexity | O(n) time, O(1) space |
get_path_winding_order()
get_path_winding_order(geometry: geo.Geometry, start_cmd_index: int) -> str
Determine the winding order of a subpath.
| Parameter | Type | Description |
|---|---|---|
geometry | geo.Geometry | Geometry to analyze. |
start_cmd_index | int | Index of the starting command. |
| Returns | str | "ccw", "cw", or "unknown". |
| Complexity | O(n) time, O(1) space |
get_subpath_area()
get_subpath_area(geometry: geo.Geometry, start_cmd_index: int) -> float
Compute the signed area of a subpath using the shoelace formula.
Positive area is CCW, negative is CW. Returns 0 for unclosed subpaths.
| Parameter | Type | Description |
|---|---|---|
geometry | geo.Geometry | Geometry to compute area from. |
start_cmd_index | int | Index of the starting command. |
| Returns | float | Signed area. |
| Complexity | O(n) time, O(1) space |
get_subpath_vertices()
get_subpath_vertices(
geometry: geo.Geometry,
start_cmd_index: int,
) -> list[tuple[float, float]]
Extract vertices from a subpath starting at the given command index.
Linearizes arcs and beziers into vertex sequences.
| Parameter | Type | Description |
|---|---|---|
geometry | geo.Geometry | Geometry to extract vertices from. |
start_cmd_index | int | Index of the starting command. |
| Returns | list[tuple[float, float]] | List of (x, y) vertices. |
| Complexity | O(n + m) time, O(m) space where n is the number of commands and m the number of output vertices |
remove_duplicates()
remove_duplicates(points: Sequence[types.Point]) -> types.Polygon
Remove duplicate points from a sequence.
| Parameter | Type | Description |
|---|---|---|
points | Sequence[types.Point] | Sequence of (x, y) points. |
| Returns | types.Polygon | List of unique points. |
| Complexity | O(n) time, O(n) space |