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

- translation

Tracker B

- single unit

- no translation

Now, 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?

Hi, the corrrect mathematical way of solving your problem is as follows:

1. get the Modelview matrix of the unit you are interested in: for example, if you have a unit which is below TrackableB, and this unit is also translated with respect to the parent trackable, you can compute the Modelview matrix of that unit as the Modelview matrix of its parent Trackable, multiplied by the local translation matrix of that unit.

2. get the modelview matrix of a unit in the other Trackable (e.g. TrackableA, if previously you were doing TrackableB), with same logic as above (note: if the unit is not translated, then just take the modelview matrix of the parent Trackable)

3. compute the relative matrix of the local reference frame of one unit (e.g. the unit in TrackableB) with respect to the reference frame of the unit in TrackableA; this can be done by multiplying one modelview matrix by the "inverse transpose" of the second matrix.

4. Then extract the distance from the resulting matrix (components 12, 13, 14 of the matrix data array).

See also:

https://developer.vuforia.com/resources/dev-guide/pose-matrix-explained

https://developer.vuforia.com/resources/dev-guide/positioning-3d-content