raygeo.geo.algo.astar

A pathfinding in an open rectangle — the shortest path is a straight line from start to goal*
AStarPath
length
length: float
visited
visited: int
waypoints
waypoints: list[tuple[float, float]]
Functions
find_path()
find_path(
from_: tuple[float, float],
to: tuple[float, float],
free_space: Sequence[Sequence[tuple[float, float]]],
obstacles: Sequence[Sequence[tuple[float, float]]] = [],
obstacle_margin: float = 0,
cell_size: float = 1,
) -> AStarPath | None
Find a path from from_ to to inside free_space, avoiding obstacles.
The walkable area is rasterised at cell_size resolution. Obstacles are dilated by obstacle_margin before pathfinding.
| Parameter | Type | Description |
|---|---|---|
from_ | tuple[float, float] | Start point (x, y). |
to | tuple[float, float] | Goal point (x, y). |
free_space | Sequence[Sequence[tuple[float, float]]] | Polygons defining the walkable region. |
obstacles | Sequence[Sequence[tuple[float, float]]] = [] | Polygons defining forbidden zones (default []). |
obstacle_margin | float = 0 | Radius by which obstacles are expanded (default 0). |
cell_size | float = 1 | Raster grid resolution (default 1.0). |
| Returns | AStarPath | None | AStarPath with waypoints, visited count, and length, or None. |

A finds a path around a central obstacle when the direct route is blocked*

A threading a path between multiple disconnected obstacles — the algorithm explores the free cells and finds an optimal route*