【发布时间】:2022-01-18 12:09:45
【问题描述】:
与前两个问题(How to calculate all 24 rotations of 3d array?,How to get all 24 rotations of a 3-dimensional array?)类似,我想找到一个物体的所有 90 度旋转。但是,我需要这些旋转的四元数。
【问题讨论】:
标签: python rotation quaternions
与前两个问题(How to calculate all 24 rotations of 3d array?,How to get all 24 rotations of a 3-dimensional array?)类似,我想找到一个物体的所有 90 度旋转。但是,我需要这些旋转的四元数。
【问题讨论】:
标签: python rotation quaternions
import numpy as np
import itertools
from pyquaternion import Quaternion
def rotations():
for x, y, z in itertools.permutations([0, 1, 2]):
for sx, sy, sz in itertools.product([-1, 1], repeat=3):
rotation_matrix = np.zeros((3, 3))
rotation_matrix[0, x] = sx
rotation_matrix[1, y] = sy
rotation_matrix[2, z] = sz
if np.linalg.det(rotation_matrix) == 1:
quat = Quaternion(matrix=rotation_matrix)
yield quat.elements
all_rotations = list(rotations())
print(len(all_rotations))
for x in all_rotations:
print(x)
基于this answer by Igor Kołakowski 的类似问题。
【讨论】: