How do you determine if a point is to the left or right of a curve?
10 views (last 30 days)
Show older comments
RAFFAELE MAGLIONE
on 22 Jun 2022
Commented: RAFFAELE MAGLIONE
on 22 Jun 2022
With reference to the images below, what I need is to establish whether the generic red point is to the right or left of the blue curve, according to the direction of travel specified by the arrow.
I have the geographic coordinates of those points available, so the first thing I tried was to calculate the distance between the generic red point and the two black lines with the Haversine formula and establish the sign based on which of these two distances is the largest, but since the circuit is not perfectly symmetrical this method does not work.
I then tried with if loops, imposing a change of sign there where there was a minimum of the distance of the red point from the blue line, but even this is not accurate.
I tried the cross product, but I think it works well only with the metric coordinates.
Do you have any suggestions?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1041425/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1041430/image.jpeg)
0 Comments
Accepted Answer
MJFcoNaN
on 22 Jun 2022
Hello,
Is "to the right" meaning that a red point is in the polygon of blue track? The function of inpolygon may help:
[in, on] = inpolygon(x_red, y_red, x_blue, y_blue);
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!