# Find closest Point based on orientation and Euclidean distance

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?

• You will have to define exactly how you want to trade off a better angular match against a better distance match. As is, your problem is not well posed. For example, a simple way is define an error metric that weights the squares of the deviations: $J = \alpha (\Delta \theta)^2 + \beta (\Delta r)^2$. – Victor Liu Oct 21 '13 at 9:19
• Hi @Victor Can u please check this Link I posted a picture to explain what I mean : link – Hani Gotc Oct 21 '13 at 9:22
• I see Yes Actually That's what i am trying to find you can say that it's a trade off between the distance and angles I see – Hani Gotc Oct 21 '13 at 9:24
• I'm going to go out on a limb and guess that you don't know what Euclidean distance actually means. Instead of using the horizontal distance and the angle, you can use the horizontal displacement (call it dx) and the vertical displacement (call it dy). Then the distance you want is sqrt(dxdx + dydy). This automatically adjusts for both the horizontal offset and the vertical angle. – k20 Oct 21 '13 at 18:09
• Naa I don't have to go that far. As @Virtor mentioned i want to find a trade-off between the distance and angle. I only had to divide the distance by the cos(theta) That's all. Y-distance / cos(\theta) – Hani Gotc Oct 23 '13 at 10:03