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

时间:2023-02-09 15:42:54

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.

我有一个点(Lat / Lon)和一个以度(真北)为标题的航向。我有许多固定多边形(在Lat / Lon中定义的点),它可能是凸的也可能不是凸的。

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.

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

4 个解决方案

#1


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

听起来你应该能够做一个简单的2d线交叉......

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

然而,我之前使用过Lat / Long并且知道它们并不完全适用于任何2d坐标系。

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.

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

#2


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

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

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.

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

#3


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.

在(我接受的)答案(我称之为h)中得到的缩放因子是“沿光线的距离是交叉点。”您正在寻找介于0和1之间的值。

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

如果有多个交叉点,那很好!如果你想要“第一个”,请使用h值最小的那个。

#4


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

这个页面上的答案似乎是最准确的。

Question 1.E GodeGuru

问题1.E GodeGuru

#1


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

听起来你应该能够做一个简单的2d线交叉......

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

然而,我之前使用过Lat / Long并且知道它们并不完全适用于任何2d坐标系。

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.

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

#2


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

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

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.

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

#3


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.

在(我接受的)答案(我称之为h)中得到的缩放因子是“沿光线的距离是交叉点。”您正在寻找介于0和1之间的值。

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

如果有多个交叉点,那很好!如果你想要“第一个”,请使用h值最小的那个。

#4


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

这个页面上的答案似乎是最准确的。

Question 1.E GodeGuru

问题1.E GodeGuru