(In reply to Daosheng Mu[:daoshengmu] from comment #0) > We might have a potential bug in Matrix4x4::Decompose(). We refer the formula from [1], but when I was trying to > > ``` > transformMatrix.RotateX(1.2f); > transformMatrix.Decompose(position, orientation, scale); > ``` > The orientation is [-0.564642, 0.000000, 0.000000, 0.825336]. IIRC, the orientation.x should be positive because we rotate degrees on +x. > > I also notice Chromium is using the same formula of Matrix.Decompose() [2] when getting a XRPose, that makes they have to do this orientation invert [3] as well. > > [1] http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm > [2] https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/platform/transforms/transformation_matrix.cc;l=567;bpv=1;bpt=1?originalUrl=https:%2F%2Fcs.chromium.org%2F > [3] https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/modules/xr/xr_rigid_transform.cc;l=37;bpv=0;bpt=1?originalUrl=https:%2F%2Fcs.chromium.org%2F According to the discussion here, https://stackoverflow.com/questions/4436764/rotating-a-quaternion-on-1-axis The proper result of a quaternion rotate x-axis with 1.2 radius should be [0.564642, 0, 0, 0.825336].
Bug 1635363 Comment 4 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
(In reply to Daosheng Mu[:daoshengmu] from comment #0) > We might have a potential bug in Matrix4x4::Decompose(). We refer the formula from [1], but when I was trying to > > ``` > transformMatrix.RotateX(1.2f); > transformMatrix.Decompose(position, orientation, scale); > ``` > The orientation is [-0.564642, 0.000000, 0.000000, 0.825336]. IIRC, the orientation.x should be positive because we rotate degrees on +x. > > I also notice Chromium is using the same formula of Matrix.Decompose() [2] when getting a XRPose, that makes they have to do this orientation invert [3] as well. > > [1] http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm > [2] https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/platform/transforms/transformation_matrix.cc;l=567;bpv=1;bpt=1?originalUrl=https:%2F%2Fcs.chromium.org%2F > [3] https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/modules/xr/xr_rigid_transform.cc;l=37;bpv=0;bpt=1?originalUrl=https:%2F%2Fcs.chromium.org%2F According to the discussion here, https://stackoverflow.com/questions/4436764/rotating-a-quaternion-on-1-axis The proper result of a quaternion rotates x-axis with 1.2 radius should be [0.564642, 0, 0, 0.825336].
(In reply to Daosheng Mu[:daoshengmu] from comment #0) > We might have a potential bug in Matrix4x4::Decompose(). We refer the formula from [1], but when I was trying to > > ``` > transformMatrix.RotateX(1.2f); > transformMatrix.Decompose(position, orientation, scale); > ``` > The orientation is [-0.564642, 0.000000, 0.000000, 0.825336]. IIRC, the orientation.x should be positive because we rotate degrees on +x. > > I also notice Chromium is using the same formula of Matrix.Decompose() [2] when getting a XRPose, that makes they have to do this orientation invert [3] as well. > > [1] http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm > [2] https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/platform/transforms/transformation_matrix.cc;l=567;bpv=1;bpt=1?originalUrl=https:%2F%2Fcs.chromium.org%2F > [3] https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/modules/xr/xr_rigid_transform.cc;l=37;bpv=0;bpt=1?originalUrl=https:%2F%2Fcs.chromium.org%2F According to the discussion here, https://stackoverflow.com/questions/4436764/rotating-a-quaternion-on-1-axis The proper result of a quaternion rotates x-axis with 1.2 radian should be [0.564642, 0, 0, 0.825336].