# Translation from one coordinate system to another having Z-offset issues

I'm using ARToolkit to do an augmented reality application, but my problem is really with the 3D coordinates.

In this application, I use my webcam to generate the scene. I have two markers (printed - they have a thick black border with a letter inside to signify which object is to be drawn), and when the ARtoolkit framework recognizes the object, it will draw a specific OpenGL object on top of the marker in real time.

So onto the actual problem.

The first marker I consider to be my world coordinates, and the second to be a floating object that I will move around the scene.

The overall problem is that when I translate my secondary object to my world coordinate system, the Z-value is typically way off from what it should be, and I'm not sure how to rectify this (this is really my first foray into 3D programming).

As a note, I get the OpenGL 1x16 matrix in from the ARToolkit, using the recognized marker as (0,0,0).

First, I take the world coordinate system marker, store it into a 4x4 matrix, and then create a variable to hold its affine inverse (I am using a framework to do this part, so I don't think it is anything I'm doing here).

Next, I take the secondary marker and store that into a 4x4 matrix.

Finally, to move the secondary marker into the world coordinate system, I multiply them in-order, together, as such:

new_coords = world_coords_affine * secondary_coords


For my understanding, this should take the secondary object and move it to the world coordinates, so that I can simply draw it based on the new x, y and z values.

As I mentioned however, the Z coordinate is far greater than it should be. I am drawing my scene typically at about (0, 0, 50) to hide the markers in the scene, and the secondary object tends to have Z-coordinates in the thousands when it is debugged. For reference, I am actually putting the two markers directly next to each other, so really there should only be an X-offset (which I am seeing at least).