我有數組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
提交
取消