The intersection point of polygon rays on the surface of a sphere

I have a point (Lat / Lon) and a heading in degrees (true north) for which this point moves along. I have many stationary polygons (Points defined in Lat / Lon) that may or may not be convex.

My question is: how to calculate the closest intersection point, if any, with the polygon. I saw some confusing reports about Ray Tracing, but they all seem to refer to 3D when Ray and Polygon are not on the same plane, and also Polygons should be convex.

+4
source share
4 answers

The answer on this page seems the most accurate.

Question 1.E GodeGuru

0
source

it sounds like you have to make a simple intersection of two lines ...

However, I have worked with Lat / Long before and I know that they are not entirely true for any 2nd coordinate system.

I would start with the general function "IsPointInPolygon", you can find a million of them in a search query, and then test it on your poly to see how well it works. If they are accurate enough, just use this. But it is possible that due to the non-quadratic lat / long coordinates, you may need to make some changes using spherical geometry.

+1
source

In 2D, calculations are simple enough ...

You can always start by checking that the endpoint of the ray is not inside the polygon (since the intersection point in this case).

If the endpoint is outside the line, you can intersect the beam / line segment with each of the boundary features of the polygon and use the closest location found. This handles convex / concave functions, etc.

+1
source

Calculate whether each line segment in a polygon crosses a ray using this method .

The resulting scale factor in (my accepted) answer (which I called h ): "How far along the beam is the intersection." You are looking for a value between 0 and 1 .

If there are several intersection points, this is great! If you want "first", use the one with the smallest h value.

+1
source

All Articles