1

There are a lot of similar questions, but I can't find the answer =(. I get a quaternion from the sensor in right hand coordinate system. Then I draw an object in the Unity by this quaternion. Unity uses left handed cordinate system. And if I rotate sensor clockwise by one axis, one axis will always rotate in the opposite direction =( I've read a lot of books, articles, forums posts for about 3 weeks. And I still can't find a solution.

I've tested follow algorithms: 1. Convert quaternion to matrix -> then convert matrix to left handed CS ( determinaте will be -1) -> and convert back to quaternion - this doesn't work.

Transformation matrix (3x3) = 1 0 0 0 1 0 0 1 -1

Matrix in new CS = (Transformation matrix)(q_mat)(Transformation matrix)

  1. Flip two component of quaternion also will save right CS. It will flip two axis.

And a lot of other methods.... Please help =(((

Headhunter Xamd
  • 576
  • 1
  • 4
  • 23
Arthur
  • 11
  • 1
  • 4

1 Answers1

3

If you want to convert right-handed coordinate to Unity's left handed coordinate, use the function below:

private Quaternion rightCoordToUnityCord(Quaternion q)
{
    return new Quaternion(q.x, q.y, -q.z, -q.w);
}

It came from Unity's doc and I've been using it since I found it. Hopefully it will solve your problem.

Programmer
  • 121,791
  • 22
  • 236
  • 328