Ray-Polygon Intersection Point on the surface of a sphere

拜拜、爱过 提交于 2019-12-05 12:41:15

sounds like you should be able to do a simple 2d line intersection...

However I have worked with Lat/Long before and know that they aren't exactly true to any 2d coordinate system.

I would start with a general "IsPointInPolygon" function, you can find a million of them by googling, and then test it on your poly's to see how well it works. If they are accurate enough, just use that. But it is possible that due to the non-square nature of lat/long coordinates, you may have to do some modifications using Spherical geometry.

In 2D, the calculations are fairly simple...

You could always start by checking to make sure the ray's endpoint is not inside the polygon (since that's the intersection point in that case).

If the endpoint is out of the line, you could do a ray/line segment intersection with each of the boundary features of the polygon, and use the closest found location. That handles convex/concave features, etc.

Jason Cohen

Compute whether the ray intersects each line segment in the polygon using this technique.

The resulting scaling factor in (my accepted) answer (which I called h) is "How far along the ray is the intersection." You're looking for a value between 0 and 1.

If there are multiple intersection points, that's fine! If you want the "first," use the one with the smallest value of h.

user66332

The answer on this page seems to be the most accurate.

Question 1.E GodeGuru

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!