fix bugs in check a position inside the polygon (#701)

* fix bugs in check a position inside the polygon

It is possible that the position `(iox, ioy)` to be checked with `iox == min_x`. This will cause a incorrect inside check.

* add a boundary condition for gridmap
This commit is contained in:
jsbyysheng
2022-08-07 13:19:47 +08:00
committed by GitHub
parent 7716bdd248
commit f40b750cca
2 changed files with 5 additions and 5 deletions

View File

@@ -194,7 +194,7 @@ class GridMap:
min_x, max_x = x[i2], x[i1]
else:
min_x, max_x = x[i1], x[i2]
if not min_x < iox < max_x:
if not min_x <= iox < max_x:
continue
tmp1 = (y[i2] - y[i1]) / (x[i2] - x[i1])
@@ -226,8 +226,8 @@ class GridMap:
def test_polygon_set():
ox = [0.0, 20.0, 50.0, 100.0, 130.0, 40.0]
oy = [0.0, -20.0, 0.0, 30.0, 60.0, 80.0]
ox = [0.0, 4.35, 20.0, 50.0, 100.0, 130.0, 40.0]
oy = [0.0, -4.15, -20.0, 0.0, 30.0, 60.0, 80.0]
grid_map = GridMap(600, 290, 0.7, 60.0, 30.5)