I have a set of points P1(x1,y1), P2(x2,y2), P3(x3,y3), P4(x4,y4), P5(x5,y5) in the Cartesian plane. I am trying to find the closest point to P1 based on the orientation and Euclidean distance. What I mean is the following:Suppose that P3 is the closet to P1 and P5 is the second closest, but the angle between P1 and P3 is greater than the angle between P1 and P5.How can I find this balance between the points?
Find closest Point based on orientation and Euclidean distance
heuristics;nearest neighbors
Unless you have a huge number of points, you can just do a linear search through the sorted list to evaluate your error metric, trying to find the smallest value. You might be able to do slightly better if you sort them all by distance away from your query point, in increasing order, then you likely only have to search the beginning portion of the sorted list.But as I mentioned above in the comments, you don't seem to know exactly how you want to gauge nearness, so I can't give you a more detailed solution.