问题描述
如何确定点是位于地球表面上的多边形的内部还是外部?
多边形的内部可以通过右手规则,即。当你在多边形周围走动时,多边形的内部在你的右侧。
多边形可能
- b
- 跨越180经度
- 覆盖全球超过50%
由于地球是一个球体,正常的射线穿越算法无法正常工作。 其实,正常的射线跟踪和缠绕规则方法在球体的表面上工作得很好,稍作调整。
在球体的表面上,直线是一个大圆,距离是以角度单位而不是米或英寸来衡量的。从球体表面的任意点绘制射线只需通过任意点和球体表面上的任意点形成一个大圆。为了保持数学的清洁,请从距离您所测试位置的点上选择第二个距离pi / 2的点。应用通常的奇偶规则到大圆和你的测试多边形。
蜿蜒规则也直接从平面上的直线转化为大圆圈在球体上。
现在您只需要基本球形几何操作的Java实现。我对这方面没有任何建议,但我想互联网会有所帮助。对于数学,从开始。
另一种方法是将你的点和多边形从球体表面投射到平面上 - 这就是地图投影所做的 - 内部的拓扑关系不会受到这种转换的影响。
b$ b
哦,如果你的多边形描述了一个大圆圈你必须决定该怎么做
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.
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
这篇关于是位于地球表面上的多边形内部或外部的一个点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!