import itertools import numpy as np from scipy.spatial.transform import Rotation out = [] for perm in itertools.permutations(range(3)): for signs in itertools.product([1, -1], repeat=3): M = np.zeros((3, 3)) for i, p in enumerate(perm): M[i, p] = signs[i] if abs(np.linalg.det(M) - 1.0) < 1e-6: out.append(M) print("всего разворотов: %d" % len(out)) for idx in (22, 18, 19, 15): M = out[idx] R = Rotation.from_matrix(M) rv = R.as_rotvec() ang = float(np.linalg.norm(rv)) ax = np.round(rv / ang, 3) if ang > 1e-9 else np.zeros(3) print("") print("#%d" % idx) print(M.astype(int)) print(" ось %s угол %.1f градусов" % (ax, np.degrees(ang))) print(" кватернион xyzw %s" % np.round(R.as_quat(), 4))