I'm trying to implement Lee's visibility graph.
There might be n number of polygons, where each side of the polygon is an edge. Let's say there is a point p1, and a half-liner parallel to the positive x-axis start at p1. I need to find edges that are intersected by r, and store them in sorted order.
An edge that is intersected first by line r has higher priority, also an edge that's closer has a higher priority, but when seen > distance.
E.g p1 = (0, 1), and a polygon with the following vertices {(2, 4),(3,6),(5, 20)}. The edges for this polygon should be sorted as [((2, 4),(5, 20)), ((2,4),(3, 6)), ((3, 6),(5, 20))].
Hence, how can I sort these edges?
(if you go to the link and read that, I think you will have a better idea, sorry for my explanation).
My prime idea: sort them by distance and angel from p1 to the first Vertex of the edge encountered by r. Though, all vertices have more than one edge (since each vertex/edge is part of a polygon), and I don't know how to sort these two.
Any ideas or hints would be much appreciated.
Just some references: https://taipanrex.github.io/2016/10/19/Distance-Tables-Part-2-Lees-Visibility-Graph-Algorithm.html And a book: Computational Geometry ALgorithms and Application.