coordinate_1 = np.array([[(np.cos(0) * np.cos(alpha_radian), np.cos(0) * np.sin(alpha_radian) * np.sin( alpha_radian) - np.sin(0) * np.cos(alpha_radian), np.cos(0) * np.sin(alpha_radian) * np.cos(alpha_radian))], [np.sin(0) * np.cos(alpha_radian), (np.sin(0) * np.sin(alpha_radian) * np.sin( alpha_radian)) - ( np.cos(0) * np.cos(alpha_radian)), (np.sin(0) * np.sin(alpha_radian) * np.cos( alpha_radian)) - ( np.cos(0) * np.sin(alpha_radian))], [-np.sin(alpha_radian), np.cos(alpha_radian) * np.sin(alpha_radian), np.cos(alpha_radian) * np.cos(alpha_radian)]])print(coordinate_1)print(type(coordinate_1))并输出[list([(0.7071067811865476, 0.4999999999999999, 0.5)])list([0.0, -0.7071067811865476, -0.7071067811865475])list([-0.7071067811865475, 0.5, 0.5000000000000001])]<class 'numpy.ndarray'>为什么矩阵输出总是在开始矩阵处包含一个“列表” ,如何将它们转换为浮点数,我可以进行一个简单的矩阵乘法。
1 回答
小唯快跑啊
TA贡献1863条经验 获得超2个赞
我不确定为什么这些是列表,但我认为你更大的问题是你试图强加看起来像 3d 旋转的元素,对吗?
如果是这样,请不要使用当前的实现,而是使用 scipy.spatial.transform.Rotation`。
那里的例子:
from scipy.spatial.transform import Rotation as R r = R.from_euler('xyz', angles=[-45, 45, 0], degrees=True) r.as_matrix()
这输出:
array([[ 7.07106781e-01, -5.00000000e-01, 5.00000000e-01], [-5.55111512e-17, 7.07106781e-01, 7.07106781e-01], [-7.07106781e-01, -5.00000000e-01, 5.00000000e-01]])
这和你的很相似。只需根据您使用的 alpha_radians 来调整角度即可。
这比写那些令人头痛的行要好得多:)
添加回答
举报
0/150
提交
取消