Now let me build this. I'll update the title, create the pathfinding algorithm module, and build the interactive app.
Now let me create the pathfinding algorithm. This is the core — visibility graph on tangent points with obstacle-containment filtering, using Dijkstra.
Now the main app. I'll build an interactive canvas with touch/mouse gestures, mode switching, radius control, and visualization.
Let me improve the algorithm. I realized there's a subtle correctness issue with non-convex merged obstacles (overlapping circles) — the shortest path can travel along the obstacle boundary, and must pass through circle-circle intersection points. Let me add those to the node set.
Let me fix a UX issue — when tapping on an existing circle in add mode, it should select that circle instead of creating a duplicate:
Let me make one more UX fix — when transitioning from a pinch (2 fingers) back to 1 finger, the drag state needs to reset so the remaining finger can continue panning smoothly:
Let me clean up a redundant check in the pathfinding early exit and also add a small improvement — show start/end position coordinates when user hovers on them:
Let me do a final verification of the complete pathfinding module:
The build succeeds and the app is complete. Here's a summary of what was built:
Circle Pathfinder — an interactive visualization tool for computing the optimal path between two points around circular obstacles on an infinite 2D plane.
Core algorithm (src/pathfinding.ts)
Builds a visibility graph over geometric feature points and solves with Dijkstra:
- Tangent points from start/end to each circle (point-to-circle tangents)
- External tangents between every circle pair (stay valid even when circles overlap)
- Internal tangents between disjoint pairs only
- Circle–circle intersection points (critical for paths that follow the boundary of a non-convex merged obstacle)
- Nodes are filtered: any point inside any obstacle is discarded
- Edges are filtered: any segment that crosses any obstacle interior is discarded
- This naturally handles overlapping circles — the merged boundary is traversed correctly
UI/UX (src/App.tsx)
- Modes: Select (drag to move), Add circle (tap to place), Set Start, Set End
- Radius control: slider + numeric input for both the new-circle radius (when adding) and the selected circle
- Pan & zoom: one-finger drag to pan, pinch or wheel to zoom, with
touch-none to avoid browser scroll conflicts
- Selected-circle panel with live radius slider, numeric input, coordinates, and delete
- Floating zoom/reset buttons for quick navigation
- Path display: glowing green line with vertex markers, live length readout
- Optional visibility-graph overlay to see the underlying search graph
- Demo scene with 7 circles including a heavily overlapping pair — shows the non-convex boundary handling
- Contextual mode hints (top-center pill), unreachable-state warning, dark theme, fully mobile-first layout using
100svh and responsive toolbar
Files built: index.html, src/pathfinding.ts, src/App.tsx