I am currently working on an application utilizing Vuforia and i need to extract position coordinates (x, y, z) from a 4x4 transformation matrix of an area target.
Here is the method VuMatrix44F i use to access the position values, which I obtain as follows from an AreaTargetObservation:
VuMatrix44F poseMatrix = poseInfo.pose;
float x = poseMatrix.data[12];
float y = poseMatrix.data[13];
float z = poseMatrix.data[14];
However, the coordinates (x, y, z) extracted from the matrix do not seem to align well with the size and position of the area target
My questions are:
Thank you.
The Vuforia target observation pose is equivalent to the model matrix in OpenGL (see here https://www.opengl-tutorial.org/beginners-tutorials/tutorial-3-matrices/#the-model-matrix).
The coordinates (x, y, z) you are using are the position of the origin of the Area Target in the Vuforia world coordinate system.
If you want to compute the position of the device in the AreaTarget coordinate system you have to combine that pose with the device tracker pose which one can get with
VuRenderState renderState;
vuStateGetRenderState(state, &renderState);
// combine the view matrix with the model matrix
auto modelView = vuMatrix44FMultiplyMatrix(renderState.viewMatrix, poseInfo.pose);
this matrix now contains the position of the AreaTarget origin in the device coordinate system. To get the position of the device in the AreaTarget you have to invert this matrix with:
auto deviceMatrix = vuMatrix44FInverse(modelView);
and then as you did
float x = deviceMatrix.data[12];
float y = deviceMatrix.data[13];
float z = deviceMatrix.data[14];