Currently my application can detect square markers and obtain the camera transform relative to each found marker. What I want to do is find out the euler rotation matrix I would need to apply to one of the markers in order for it to match the orientation of the other. I want to get the x,y,z rotation.
So far I have tried the following:
if (arCamera.imarker.FindMarker(0) && arCamera.imarker.FindMarker(1))
{
Matrix mt = Matrix.Invert(markerTransforms[0]) * markerTransforms[1];
Vector3 scale;
Vector3 trans;
Quaternion rot;
mt.Decompose(out scale, out rot, out trans);
Vector3 vp= QuaternionToEuler(rot);
spriteBatch.DrawString(garamond14I, vp.X.ToString("0.00"), new Vector2(5, 5), Color.White);
spriteBatch.DrawString(garamond14I, vp.Y.ToString("0.00"), new Vector2(50, 5), Color.White);
spriteBatch.DrawString(garamond14I, vp.Z.ToString("0.00"), new Vector2(95, 5), Color.White);
}
I got the QuaternionToEuler code from: http://forums.create.msdn.com/forums/p/4574/23763.aspx
This gets me the an incorrect result. Here is a screenshot of the running application:
The actual rotation should be: x:0 y:0 z:-0.52
I also noticed that the rotation changed for both the y axis and z axis as I moved the camera around.
The two transform matrices I obtain from the marker detector contain the orientation and translation of the camera relative to one of the markers as explained here: http://www.hitl.washington.edu/artoolkit/documentation/tutorialcamera.htm
I have converted them to XNA format and I know them to work correctly as I can draw the corners onto the screen and it matches up with what the camera is seeing.
Essentially I want to get the rotation that will get marker 1 to match the orientation of marker 0, in the above example a rotation around of z axis of -0.52 will achieve this. This is based on marker 0's coordinate system with the axis centered on the middle of the marker as shown below: