Skip to content

Instantly share code, notes, and snippets.

@yubaoliu
Last active January 8, 2020 07:53
Show Gist options
  • Save yubaoliu/3edd2cfde1e9d508110481619669ea9e to your computer and use it in GitHub Desktop.
Save yubaoliu/3edd2cfde1e9d508110481619669ea9e to your computer and use it in GitHub Desktop.
Convert right hand coordinate to left hand coordinate
Solution 1:
This is from website, however I don't think it's ritht.
static function MayaRotationToUnity(rotation : Vector3) : Quaternion {
var flippedRotation : Vector3 = Vector3(rotation.x, -rotation.y, -rotation.z); // flip Y and Z axis for right->left handed conversion
// convert XYZ to ZYX
var qx : Quaternion = Quaternion.AngleAxis(flippedRotation.x, Vector3.right);
var qy : Quaternion = Quaternion.AngleAxis(flippedRotation.y, Vector3.up);
var qz : Quaternion = Quaternion.AngleAxis(flippedRotation.z, Vector3.forward);
var qq : Quaternion = qz * qy * qx ; // this is the order
return qq;
}
Solution 2:
Right hand (IMU):
Quaternion(q0,q1,q2,q3)
Right => Left(unity)
Quaternion(q1, -q3, q2, q0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment