# Shortest path in polygon from 2 points such that entire polygon is visible

Given an isothetic polygon (sides parallel to the x-axis or y-axis) and 2 points (start and end) on the boundary of the polygon, find the shortest path traveling only in the direction of the x or y axis (up, right, down, left), such that the entire polygon is visible by the time a point travels from the start point to the end point.

Does anyone know of an algorithm that solves the above problem statement? No requirements on running time as such.

The best I could come up with was probably:-

1. Triangulate the polygon
2. 3-color each vertex of the triangles such that no two vertices on an edge have the same color
3. Choose the color with the minimum count, and then join them to form the path

But this does not form the path which is given in the question. Moreover, it is a heuristic, which is not really what is required.

• Is the polygon simple (i.e. without holes)? Is the visibility axis-parallel as well: are all the points $w$ s.t. $vw$ lies in the polygon considered visible from $v$, or does $vw$ need to be axis-parallel? This paper provides an algorithm for the case of polygonal paths and where the endpoints of the path can be freely chosen by the algorithm. I don't see a way to directly apply the result to your case, but their approach is likely relevant. Nov 30, 2023 at 9:21
• The polygon is simple A point is visible from another point if you can draw a line between them (axis-parallel or not) without obstructing with boundary of the polygon. Thanks for the paper, it does seem useful Nov 30, 2023 at 10:09
• this does not form the path which is given in the question In general, there should be many shortest paths. Dec 1, 2023 at 10:55
• What I meant is that it does not form a path that is axis-parallel, it goes in angles from vertex to vertex. You are right, there might be many shortest paths. Any of those shortest paths (axis-parallel) will do. Dec 1, 2023 at 14:30