Skip to content

Commit

Permalink
fix bug with path collisions for simplifying paths
Browse files Browse the repository at this point in the history
  • Loading branch information
seveibar committed Jan 9, 2025
1 parent 9b43f87 commit 248327a
Show file tree
Hide file tree
Showing 6 changed files with 634 additions and 28 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,18 @@ test("shorten-path-with-shortcuts 3 with obstacle", () => {
const obstacleList = new ObstacleList(obstacles as Obstacle[])

const simplifiedPath = shortenPathWithShortcuts(pathToOptimize, (A, B) => {
const minX = Math.min(A.x, B.x)
const minY = Math.min(A.y, B.y)
const maxX = Math.max(A.x, B.x)
const maxY = Math.max(A.y, B.y)
return (
obstacleList.getObstaclesOverlappingRegion({
minX,
minY,
maxX,
maxY,
}).length > 0
const collision = obstacleList.getOrthoDirectionCollisionInfo(
A,
{
dx: Math.sign(B.x - A.x),
dy: Math.sign(B.y - A.y),
},
{
margin: 0.05,
},
)
const dist = Math.sqrt((A.x - B.x) ** 2 + (A.y - B.y) ** 2)
return collision.wallDistance < dist
})

expect(
Expand Down
Loading

0 comments on commit 248327a

Please sign in to comment.