我有以下数组:
[[[623 284]]
[[526 256]]
[[532 189]]
[[504 166]]
[[323 175]]
[[276 219]]
[[119 221]]
[[ 1 272]]
[[ 0 473]]
[[615 479]]]
这些是多边形的点(坐标)。我需要做的是迭代这个数组,取每个点来计算多边形中的每个内角。我有这个函数来计算3个点之间的角度:getAngle((px1, py1), (px2, py2), (px3, py3))
。
基本上,我想把这个函数放在一个循环中,它会分别取点,比如:
getAngle((623, 284), (526, 256), (532, 189)),
getAngle((526, 256), (532, 189), (504, 166)),
getAngle((532, 189), (504, 166), (323, 175)),
等等,直到最后。。。 它应该是哪个循环以及如何实现它
more_itertools
是一个很好的库,可以存储以下内容:因为你有点(作为一个numpy数组)并且你想要角度(符号角度),这里有一个完整的解决方案
这将使用整个数组操作
注意Yves Daoust在评论中的非常有效的评论。此演示无法正确处理锐角,但可以通过额外的向量检查和角度校正来处理锐角
一些图纸:
一个简单的
?
勘误表:
相关问题 更多 >
编程相关推荐