简体   繁体   English

如何查找点位于线或面内

[英]How to find a point is located inside a line or polygon

I found a point is located inside a Circle using following method. 我使用以下方法发现了一个点位于圆内。

  • Distance between a point and circle center <= circle radius means the point is inside circle. 点与圆心的距离<=圆半径表示圆心在圆内。

But I need to find 但我需要找到

  • The point is located in a line 该点位于一条直线上
  • The point is located in a polygon 该点位于多边形中

Normally polyline has array of coordinates,if i check with all points in-between points will miss while calculating. 通常,折线具有坐标数组,如果我检查所有点之间的点,将在计算时错过。

Update: 更新:

I used github.com/sromku/polygon-contains-point to find the point is located in a polygon. 我使用github.com/sromku/polygon-contains-point找到位于多边形中的点。 But it is 2D normal plane. 但这是2D法线平面。 But I need to find a point inside a Polygon calculation on spheroid.How to do this? 但是我需要在球体的Polygon计算中找到一个点,该怎么做?

q2: search for "point in polygon strategies", from graphic gems. q2:从图形宝石中搜索“多边形策略中的点”。
Point in Polygon also works if the coordinates are longitude (x), latitude (y). 如果坐标是经度(x),纬度(y),则多边形中的点也可以使用。 At least the algo that count for line crossings, which mostly are the one implemented. 至少算在内的算法是跨行,大多数是实现的算法。 Of course if the polygn crosses the datum limit (by ship or plane) or is located at the polar region, then this does not work with the simple apporach. 当然,如果polygn越过基准点限制(通过船舶或飞机)或位于极地,则使用简单的方法就不起作用。

q1: point line: in school you learned that (abs(normal distance to line) < epsilon) but what you need is distance to line segment . q1:点线:在学校,您了解到(绝对(到线的正常距离)<epsilon),但是您需要的是distance to line segment (not line which has infinity length). (不是无限长的线)。

For this task you have to transfrom to cartestioan coordinates first. 对于此任务,您必须先转换为角叉虫坐标。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM