是地球表面上的多边形内部或外部的点
如何确定一个点是位于地球表面上的多边形内部还是外部?
多边形的内部可以通过右手定则确定,即当您围绕多边形行走时,多边形的内部位于您的右手边。
多边形可以
- 绕任一极
- 穿过 180 度经度
- 覆盖地球的 50% 以上
由于地球是球体,正常的射线交叉算法无法正常工作。
How do I determine if a point is inside or outside a polygon that lies on the the surface of the earth?
The inside of the polygon can be determined via the right hand rule, ie. the inside of the polygon is on your right hand side when you walk around the polygon.
The polygon may
- Circle either pole
- Cross the 180 longitude
- Cover more than 50% of the globe
As the globe is a sphere the normal ray crossing algorithms do not work correctly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
事实上,普通光线追踪和缠绕规则方法在球体表面上效果很好,只需稍加调整。
在球体表面上,“直线”是一个大圆,距离以角度单位而不是米或英寸来测量。要从球体表面上的任意点绘制射线,只需通过该任意点和球体表面上的任何其他点形成一个大圆即可。为了保持数学清晰,选择距离您正在测试的位置点大约 pi/2 的第二个点。将通常的奇偶规则应用于大圆和测试多边形。
缠绕规则还可以直接从平面中的直线转换为球体上的大圆(的片段)。
您现在所需要的只是基本球面几何操作的 Java 实现。我在这方面没有任何建议,但我想互联网会有所帮助。对于数学,请从 Mathworld 开始。
另一种方法是将点和多边形从球体表面投影到平面 - 这就是地图投影所做的 - 内部的拓扑关系不会受到这种变换的影响。
哦,如果你的多边形描述了一个大圆,你必须决定该怎么做
In fact the normal ray tracing and winding rule approaches work just fine on the surface of a sphere, with a little adjustment.
On the surface of a sphere a 'straight line' is a great circle and distances are measured in angular units rather than metres or inches. To draw a ray from an arbitrary point on the surface of the sphere simply form a great circle through that arbitrary point and any other point on the surface of the sphere. To keep the maths clean choose a second point about pi/2 away from the point whose location you are testing. Apply the usual even-odd rule to the great circle and your test polygon.
The winding rule also translates directly from straight lines in the plane to (segments of) great circles on a sphere.
All you need now are Java implementations of basic spherical geometry operations. I don't have any recommendations on that front, but I guess the Internet will help. For the maths start with Mathworld.
Another approach would be to project your points and polygons from the surface of the sphere to the plane -- which is what map projections do -- the topological relationship of insideness will not be affected by such a transformation.
Oh, and you'll have to decide what to do if your polygon describes a great circle
使用平面而不是射线。球体表面上由两点定义的“线”是大圆(其中心是球体中心的圆)的弧,并且也包含在包含这两个点和球体中心的平面中。
测试该点是否“大于”或“小于”“多边形”每条边的相应平面,以确定它位于“线”的哪一侧。
Use planes instead of rays. A "line" on the surface of a sphere defined by two points is an arc of a great circle (circle whose center is the center of the sphere) and is also contained in a plane that contains those two points and the center of the sphere.
Test whether the point is "greater" or "less" than the corresponding plane for each edge of the "polygon" to determine which side of the "line" it is on.