I have a quaternion, coming from a system with the following:(intertial sensor)

Right handed.
Forward direction: Y axis
Right direction: X axis
Up direction: Z axis

I need to convert this into a coordinate system that is: (Unreal engine)

Forward direction: X axis
Right direction: Y axis
Up direction: Z axis

I have tried negating the axis, and angle, I have tried switching values, i cannot get this to work. All help greatly appreciated! I am working in C#, with Microsoft.Xna.Quaternion.

  • 1
    \$\begingroup\$ Is your situation a duplicate of this SO question Convert quaternion from right-handed to left-handed coordinate system? \$\endgroup\$
    – Pikalek
    Commented Aug 30, 2016 at 22:15
  • \$\begingroup\$ @Pikalek Reading the title i'd say yes, however as you read OP's question, it seems he's not really interested in right-left-handedness but instead in swapping the uses of the x and y axis \$\endgroup\$
    – Brian H.
    Commented Nov 3, 2017 at 8:34
  • \$\begingroup\$ There are many similar posts but I added an answer that i found works in this other post. Hope it helps. stackoverflow.com/questions/39040325/… \$\endgroup\$
    – aheigins
    Commented Nov 22, 2022 at 11:38

2 Answers 2


To convert the Quaternion, we need to convert the imaginary part (xyz) which represents the axis of rotation into the destination coordinate system. In this case, that means exchanging x & y while leaving z unchanged.

Then, because we've changed the handedness of our coordinate system, our angle takes the opposite sign (a +ve rotation in a right-handed coordinate system is a -ve rotation about the corresponding axis in a left-handed coordinate system). This leaves the real part (w) unchanged, since cos(theta) = cos(-theta), and negates the imaginary part, since sin(theta) = -sin(-theta)

Combining these two effects, we get the following:

Quaternion ConvertSensorToUnreal(float x, float y, float z, float w) {

    Quaternion output;
    output.x = -y;
    output.y = -x;
    output.z = -z;
    output.w = w;

    return output;

Rotation - counter clockwise is +ve and clockwise is -ve

Rx(90)*Rz(-90)*Ry(90) will switch in the way you wanted. Either you perform these rotation using quaternions or convert them into DCM (Direction Cosine Matrix) and then perform the rotation and convert back to quaternions.

I hope this will solve your issue.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .