我有数组length = 7angle = 30 x = [1.21660254e+02, 1.71660254e+02, 2.38660254e+02, 2.05660254e+02]我试过这个P2x = int(np.round(x + length * math.cos(math.radians(-angle))))给我错误TypeError: only size-1 arrays can be converted to Python scalars
1 回答
偶然的你
TA贡献1841条经验 获得超3个赞
math如果您已经在使用,则不需要该模块numpy
import numpy as np
length = 7
angle = 30
x = [1.21660254e+02, 1.71660254e+02, 2.38660254e+02, 2.05660254e+02]
xP2x = np.round(np.array(x) + length * np.cos(np.radians(-angle))).astype(int)
print(xP2x)
出去:
[128 178 245 212]
添加回答
举报
0/150
提交
取消