-->

分類

2017年6月8日 星期四

[Note] convert transform matrix from right-handed coordinate system to left-handed coordinate system

Rotation:
angle: rotate negated angle
axis: negate z component

https://butterflyofdream.wordpress.com/2016/07/05/converting-rotation-matrices-of-left-handed-coordinate-system/
https://www.evl.uic.edu/ralph/508S98/coordinates.html

Translation:
negate z component

Then you have things like SteamVR pose to Unity pose conversion in SteamVR_Utils in Unity's SteamVR plugin:

                 public RigidTransform(HmdMatrix34_t pose)
{
var m = Matrix4x4.identity;

m[0, 0] =  pose.m0;
m[0, 1] =  pose.m1;
m[0, 2] = -pose.m2;
m[0, 3] =  pose.m3;

m[1, 0] =  pose.m4;
m[1, 1] =  pose.m5;
m[1, 2] = -pose.m6;
m[1, 3] =  pose.m7;

m[2, 0] = -pose.m8;
m[2, 1] = -pose.m9;
m[2, 2] =  pose.m10;
m[2, 3] = -pose.m11;

this.pos = m.GetPosition();
this.rot = m.GetRotation();
}

沒有留言:

張貼留言