Created
November 1, 2015 14:48
-
-
Save baku89/b9309cdd7d5adc3b4b70 to your computer and use it in GitHub Desktop.
Extract quaternion in right-hand rule from affine matrix in left-hand rules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://afni.nimh.nih.gov/pub/dist/src/pkundu/meica.libs/nibabel/eulerangles.py | |
import eulerangles | |
import c4d | |
threeMat = c4d.Matrix().Scale(c4d.Vector(1, 1, -1)) | |
def mat2quat(mat): | |
mt = threeMat * m | |
v1, v2, v3 = mat.v1, mat.v2, mat.v3 | |
rotMat = [ | |
[v1.x, v1.y, v1.z], | |
[v2.x, v2.y, v2.z], | |
[v3.x, v3.y, v3.z] | |
] | |
euler = eulerangles.mat2euler(rotMat) | |
quat = eulerangles.euler2quat(euler.z, euler.y, euler.x) | |
return [quat[1], quat[2], quat[3], quat[0]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment