球体表面上的射线-多边形交点

发布于 2024-07-15 08:11:57 字数 184 浏览 5 评论 0原文

我有一个点(纬度/经度)和一个以度为单位的航向(正北),该点沿着该点行进。 我有许多固定多边形(以纬度/经度定义的点),它们可能是凸的,也可能不是凸的。

我的问题是,如何计算与多边形最近的交点(如果有)。 我看过一些关于光线追踪的令人困惑的帖子,但当光线和多边形不在同一平面上并且多边形必须是凸的时,它们似乎都与 3D 相关。

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

My question is, how do I calculate the closest intersection point, if any, with a polygon. I have seen several confusing posts about Ray Tracing but they seem to all relate to 3D when the Ray and Polygon are not on the same Plane and also the Polygons must be convex.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

风流物 2024-07-22 08:11:57

听起来你应该能够做一个简单的二维线相交...

但是我之前曾使用过纬度/经度,并且知道它们对于任何二维坐标系都不完全正确。

我将从通用的“IsPointInPolygon”函数开始,您可以通过谷歌搜索找到一百万个函数,然后在您的多边形上测试它,看看它的工作效果如何。 如果它们足够准确,就使用它。 但由于纬度/经度坐标的非方形性质,您可能需要使用球面几何进行一些修改。

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.

单身情人 2024-07-22 08:11:57

在 2D 中,计算相当简单......

您始终可以首先检查以确保光线的端点不在多边形内部(因为在这种情况下这是交点)。

如果端点不在直线上,您可以与多边形的每个边界特征进行射线/线段相交,并使用最近找到的位置。 处理凸/凹特征等。

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.

软甜啾 2024-07-22 08:11:57

使用此技术计算光线是否与多边形中的每条线段相交

(我接受的)答案(我称之为 h)中得到的缩放因子是“沿光线的交点有多远”。 您正在寻找 01 之间的值。

如果有多个交点,那就没问题了! 如果您想要“第一个”,请使用 h 值最小的那个。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文