I am using this api to develop an AR game.In this game, I use a tracker (Tracker A) to determine a battle field and some game unit,I have another tracker (Tracker B) to determine another game unit and all of the unit are not do any translation.Tracker A- multi unit- translationTracker B- single unit- no translationNow, i want to calculate the distance between tracker A unit and tracker B unit.But the API just return the modelview matrix and projection matrix of the tracker A and tracker B.I don't know how to get the world location of these units.I try to use following method to get the distance between tracker A and tracker B:Math.sqrt( Math.pow(trackerA.modelViewMatrix[12]- trackerB.modelViewMatrix[12], 2) + Math.pow(trackerA.modelViewMatrix[13]- trackerB.modelViewMatrix[13], 2) + Math.pow(trackerA.modelViewMatrix[14]- trackerB.modelViewMatrix[14], 2))I try to move the tracker B to test it and it seem ok, but i am not sure is it correct.I suppose above method is correct, but i cannot get the distance between tracker A unit and tracker B unit.Because the tracker A unit had been translate.Is it possible to get the world location of the game unit?
"We offer new support options and therefor the forums are now in read-only mode! Please check out our Support Center for more information." - Vuforia Engine Team
Extract world location from modelview matrix
By lth927ken
on Tue, 04/01/2014 - 08:23
Extract world location from modelview matrix
Hi, the corrrect mathematical way of solving your problem is as follows:
Extract world location from modelview matrix
Hi AlessandroB,
Thank you for your quick reply. I cannot test the program at this moment, but I have draft the code follow your step.
Please tell me if i have any misunderstanding.
1. Get the Modelview matrix of the unitA in TrackableA:
Extract world location from modelview matrix
Hi, yes, looks correct, although you are saving the inverse transpose into the same matrix "modelViewMatrixB";
Extract world location from modelview matrix
Hi
Extract world location from modelview matrix
Sorry I cannot debug your code,
but one thing you can do is to check the order of multiplication of matrices (you might need to multiply the matrices in the opposite order, as matrix multiplication is not order-independent°;
try comparing your code with this:
Extract world location from modelview matrix
Hi AlessandroB,
It is very helpful, I can get the translation value of target B base on the target A, then I can calculate the distance very easy.
Extract world location from modelview matrix
Great!