Created
March 1, 2017 18:01
-
-
Save jaburns/583d1193a00531dc1dd1576fe5319a8c to your computer and use it in GitHub Desktop.
Convert quaternion to rotation matrix
This file contains hidden or 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
float3x3 quaternionToRotationMatrix(float4 q) | |
{ | |
return float3x3( | |
1 - 2*q.y*q.y - 2*q.z*q.z , 2*q.x*q.y - 2*q.z*q.w , 2*q.x*q.z + 2*q.y*q.w, | |
2*q.x*q.y + 2*q.z*q.w , 1 - 2*q.x*q.x - 2*q.z*q.z , 2*q.y*q.z - 2*q.x*q.w, | |
2*q.x*q.z - 2*q.y*q.w , 2*q.y*q.z + 2*q.x*q.w , 1 - 2*q.x*q.x - 2*q.y*q.y | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment