1

I have 6 unit vectors (representing the X/Y/Z axis) of 2 arbitrary coordinate systems. The vector values of the second coordinate system are based on the first system. I need to rotate one system into the other and return the matching quaternion. What would be the most reasonable way to do this in c++?

There are a number of posts on SO talking about converting y-up/z-up/left-/right-handed systems into each other, unfortunately I need this to be a generic solution for any 6 unit vectors. Thanks for any insights.

2
  • What would be the most reasonable way to do this in c++? en.wikipedia.org/wiki/Euler_angles, obviously Commented Apr 22, 2016 at 12:16
  • @SeverinPappadeux not an option, i need a quaternion returned and fought with gimbal lock before using Euler angles. Commented Apr 22, 2016 at 13:22

1 Answer 1

3

3 orthogonal vectors it is probably rotation matrix 3x3. You can build 2 matrices and find relative rotation as r_relative = r1.transpose() * r2;

Than convert matrix to quaternion using any tested lib.

Or convert both rotations to quaternion and

q_relative = q1.inverted() * q2;

Sign up to request clarification or add additional context in comments.

1 Comment

thanks! since this is for motion tracking and bone orientation, i found this paper yesterday which basically confirms what you recommend, with the added info of relating my current bone orientation to the one before in the hierarchy. link under 3.1, second column