2017-10-16 19 views
1

행렬 (M)을 쿼터니언으로 변환하면 예를 들어 다음과 같이 할 수 있습니다. 비디오 프레임을 직접 만들어야하는 이미지의 부드러운 애니메이션을 만드는 두 개의 서로 다른 변환 매트릭스 사이의 차이.쿼터니언으로 돌아가는 행렬에서 같은 결과를 얻지 못합니다.

쿼터니언에서 테스트로 매트릭스로 다시 변환하면이 새로운 매트릭스는 퀘스트가 된 것과 완전히 같지 않습니다.

import numpy as np 
from transforms3d import quaternions 

M = np.array([[ 0.757403109, -0.186744161, 145.541734], 
[ -0.154492906, 0.626185286, 100.878814], 
[ -0.000294826495, -0.000344726091, 1.00000000]]) 


quat = quaternions.mat2quat(M) 


testM = quaternions.quat2mat(quat) 
print("TEST: M original") 
print(M) 
print("TEST: quat back to mat (testM)") 
print(testM) 
print("Why not the same") 
print ("quat") 
print(quat) 
print("quat of testM") 
print(quaternions.mat2quat(testM)) 

#Scaling gives same result, scale M to be -1. to 1 
mmax = np.amax(M) 
scaleTestM = M/mmax 
print("M Scaled") 
print(scaleTestM) 
quatOfScaled = quaternions.mat2quat(scaleTestM) 
print("Quat of scaled") 
print(quaternions.quat2mat(quatOfScaled)) 

쿼터니언이 실제로 표현할 수있는 것을 놓치거나 코드가 잘못 되었습니까? 이것이 작동하지 않으면 두 변환 행렬간에 원활하게 이동하는 방법에 대한 다른 제안이 인정됩니다.

파이썬 3.6

콘솔 출력은 이것이다 :

TEST: M original 
    [[ 7.57403109e-01 -1.86744161e-01 1.45541734e+02] 
    [ -1.54492906e-01 6.26185286e-01 1.00878814e+02] 
    [ -2.94826495e-04 -3.44726091e-04 1.00000000e+00]] 
    TEST: quat back to mat (testM) 
    [[ 0.38627453 -0.42005089 0.8211877 ] 
    [-0.54462197 0.61466344 0.57059247] 
    [-0.74443193 -0.6676422 0.00865989]] 
    Why not the same 
    quat 
    [ 0.70880143 -0.43673539 0.55220671 -0.04393723] 
    quat of testM 
    [ 0.70880143 -0.43673539 0.55220671 -0.04393723] 
    M Scaled 
    [[ 5.20402697e-03 -1.28309699e-03 1.00000000e+00] 
    [ -1.06150244e-03 4.30244486e-03 6.93126372e-01] 
    [ -2.02571789e-06 -2.36857210e-06 6.87088145e-03]] 
    Quat of scaled 
    [[ 0.38627453 -0.42005089 0.8211877 ] 
    [-0.54462197 0.61466344 0.57059247] 
    [-0.74443193 -0.6676422 0.00865989]] 
+0

단일 쿼터니언에 대해 참일 수있는 다중 행렬 변환이 있다고 생각합니다. – visibleman

답변

0

은 주어진 사원 수에 해당하는 다수의 행렬 표현이 있습니다. 행렬을 Quaternion으로 변환 할 때 원래 사용 된 이러한 표현에 대한 정보는 손실됩니다.

행렬 표현 - https://en.wikipedia.org/wiki/Quaternion