正如问题中我有几个要点一样,我们称它们为A,B和C(但它们可以更多),我知道它们在(x,y)中的位置。我在两个轴上的定义区域也都在[1-n]之间。我需要找到落入由A,B和C生成的多边形中的所有点。
由于我没有一组点,因此我想同时使用x和y轴的整个范围,即[1-n],作为落入A,B和C生成的多边形中的一组可能的点但是我不确定这是否可以用于该功能。
在这个阶段,我尝试了一些涉及以下功能的事情(其中一些我在SO中发现了其他问题)。
#define the range as the possible points falling in the polygon
allPointsX <- allPointsY <- c(1:2048)
#get some coordinates for three points generating the actual polygon (which in this case is a simple triangle)
xCoord <- c(127, 120, 152)
yCoord <- c(77, 96, 107)
#look for points into the polygon
points <- point.in.polygon(allPointsX, allPointsY, xCoord, yCoord)
但是或者我没有得到输出(全为零:)all(points==0)
,或者这不是我想要的。
有什么建议?我想念什么?
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句