Skip to content

Commit

Permalink
Merge pull request #104 from tscircuit/path-simplify2
Browse files Browse the repository at this point in the history
fix bug with path collisions for simplifying paths
  • Loading branch information
seveibar authored Jan 9, 2025
2 parents 9b43f87 + 248327a commit 5739d9d
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 5739d9d

Please sign in to comment.