简体   繁体   English

使用 pyquaternion 旋转向量数组

[英]Rotation of array of vectors using pyquaternion

I have a numpy ndarray of shape (112414,3).我有一个形状为 (112414,3) 的 numpy ndarray。 i want to rotate these 112414 vectors around same axis and angle using pyquaternion.我想使用 pyquaternion 围绕相同的轴和角度旋转这些 112414 个向量。 is there a way to get all rotated vectors at once instead of applying a loop of size 112414?有没有办法一次获得所有旋转的向量而不是应用大小为 112414 的循环?

rotation_axis=np.random.uniform(size=3)
my_quaternion = Quaternion(axis=rotation_axis,degrees=np.random.uniform(low=0,high=361))

for i in np.arange(len(linear_arr)):

    x=my_quaternion.rotate(Quaternion(vector=linear_arr[i])).vector

i want to remove this loop.我想删除这个循环。 i want to give complete linear_arr which is ndarray of shape (112414,3) and get an array of rotated vectors of same shape.我想给出完整的 linear_arr,它是形状 (112414,3) 的 ndarray 并获得一组相同形状的旋转向量。 because this code above is computationally expensive and taking too much time on my machine因为上面的这段代码在计算上很昂贵并且在我的机器上花费了太多时间

最好编写自己的代码来将矩阵旋转作为矩阵乘法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM