I have a marker detection system for AR at the moment, it detects markers in the scene and gives a camera conversion matrix for each marker in the scene.
Say I found 2 markers. I am trying to find a rotation matrix that I have to apply to one of the markers in order to make it match the orientation of the other marker.
I decided that it should be the same as calculating the transformation matrix of one marker to another and decomposing the transformation to get the rotation matrix x, y, z euler, but I can not get this to work. I am using C # with XNA.
In code:
Matrix marker1 = markerTransforms[0]; Matrix marker2 = markerTransforms[1]; Matrix relativeTransform = Matrix.Invert(marker1) * marker2; Quaternion rotation; Vector3 scale; Vector3 translation; relativeTransform.Decompose(out scale, out rotation, out translation); Matrix rotationMatrix = Matrix.CreateFromQuaternion(rotation);
This does not work.
Another question is how to extract the rotation matrix x, y, z of the Euler from the rotation?
EDIT:
I found a function to convert quaternion to eiler, following the x, y, z order here: http://forums.create.msdn.com/forums/p/4574/23763.aspx
Applying this to my code, I got the following results:

Actual rotation should be: x: 0 y: 0 z: -0.52
I also noticed that y and z changed a lot depending on how I positioned the camera.
The two transformation matrices that I get from the marker detector contain the orientation and translation of the camera relative to one of the markers, as described here: http://www.hitl.washington.edu/artoolkit/documentation/tutorialcamera.htm I converted them to XNA format , and I know that they work correctly, because I can draw corners on the screen, and this corresponds to what the camera sees.
math c # matrix-multiplication xna augmented-reality
Jkh2
source share