Converting xzy to xyz co-ordinate space

Hi,

I have an external move object I interface with in a DLL. It uses a XZY (its old) system.

I need to convert the localtoworld to the XZY co-ordinate space and then flip it back once its gone through the system.

Is there an easy way to do this in unity? Or am I going to have to manually make copies of the LTW, then flip it, then generate manually my pyr I need and then flip it back after.

I think the flip matrix should be:

[ 1 0 0 0 ]
[ 0 0 1 0 ]
[ 0 1 0 0 ]
[ 0 0 0 1 ]

sound about right?

Thanks

Well, there’s no built in way to change the coordinate system Unity will use. Unity always use a left-handed-system with +y == up, +z == forward and +x == right.

It depends on what system your XZY is using (left or right handed). you might need to invert one of the axis but without knowing the exact system it’s just guessing :wink:

To continue on this. I have 2 conversion matricies for the XYZ to XZY

// @param in 3d position vector in Right handed Coordinate System
// @param out 3d position vector in Unity Coordinate System
void RHSToUnity(Vector3 in, ref Vector3 out)
{ 
  out[0] = in[1]; 
  out[1] = in[2]; 
  out[2] = -in[0];
}

// @param in 3d position vector in Unity Coordinate System
// @param out 3d position vector in Right handed Coordinate System
void UnityToRHS(Vector3 in, ref Vector3 out)
{ 
  out[0] = -in[2]; 
  out[1] = in[0]; 
  out[2] = in[1];
}

They feel right to me as the RHS +y moves forward while +x is in unity isn't it?

Which leaves me with the Rotation issues I have a PYR for the helicopter.

How should it convert? its local space so technically it should just be 'right' between the two the only change would be pitch needing to be inverted yaw is around the y, roll is around the z axis? I mean roll is roll yeah? irrespective of the axis you derive it from?

I can't get me head around this. :(