Reputation: 165
Given a list of points on the same line, I need to find out the the adjacent points for each point. See the image for illustration
I know the coordinates of all the points. These points are ordered randomly in my input list.
My approach:
Ex: If p2 happens to be the first point in the list, then, assuming that the smaller angle is 30, the larger clockwise angle will be 210. So, p1 will lie in one list. p3,p4,p2 will lie in the other list. Now I can get the relative ordering of the points.
Is there any better solution?
Upvotes: 2
Views: 769
Reputation: 11020
Upvotes: 4