Hi!

I want to calculate the direction to an marker(in time, e.g. marker on 11 o'clock). I have already the cameraPosition and the LookAtVector from the Camera to the marker :

```QCAR::Matrix44F inverseModelView = SampleMath::Matrix44FTranspose(SampleMath::Matrix44FInverse(modelViewMatrix));
//    CameraPosition/LookAtVector
QCAR::Vec3F direction(inverseModelView.data[8], inverseModelView.data[9], inverseModelView.data[10]);
QCAR::Vec3F positioncam(inverseModelView.data[12], inverseModelView.data[13], inverseModelView.data[14]);
//LOG("camLookAt: %f, %f, %f", direction.data[0], direction.data[1], direction.data[2]);
LOG("camPosition: %f, %f, %f", positioncam.data[0], positioncam.data[1], positioncam.data[2]);```

Anybody an idea how to calculate an angle to get the MarkerPosition (in time) or has an other idea to get this information in time very easy?

Stephan

Hi kim ,

How can get angle of camera respect to Marker reference frame, in all X,Y,Z direction?

Thanks for the video, very helpful.
I'm using sdk version 2.5.

Here's an article explaining how 3D rotation matrices are defined - http://en.wikipedia.org/wiki/Rotation_matrix

Which SDK version are you using?

I read the doc but I still have some trouble finding the value of this angle. And couldn't find any additional resources than this article.

Would really appreciate some additional resources or some code. Thanks :)

Hi, obtaining the angle around an axis is something that can be done by processing the pose matrix with some trigonometric (math) functions;

but you need to have a clear understanding of how the pose matrix is defined, for which I recommend reading this article:

https://developer.vuforia.com/forum/faq/technical-how-pose-matrix-defined

Hi,

How can I get the angle around the X axis of the image target only ?

Lukas

Hi Kim!

The code works fine!

Thanks a lot, Stephan

Here is one approach. I may be able to think of something simpler later :)

```// take the inverse of the modelview matrix to find the camera orientation in relation to a target at the origin
QCAR::Matrix44F inverseModelView = SampleMath::Matrix44FTranspose(SampleMath::Matrix44FInverse(modelViewMatrix));

// pull the camera position and look at vectors from this matrix
QCAR::Vec3F cameraPosition(inverseModelView.data[12], inverseModelView.data[13], inverseModelView.data[14]);
QCAR::Vec3F cameraLookAt(inverseModelView.data[8], inverseModelView.data[9], inverseModelView.data[10]);

// project both vectors to the X/Y plane
// reverse the camera position to get a vector pointing to the target
QCAR::Vec3F projectedDirectionToTarget(-cameraPosition.data[0], -cameraPosition.data[1], 0);
QCAR::Vec3F projectedCameraLookAt(cameraLookAt.data[0], cameraLookAt.data[1], 0);

// normalize the projected vectors
projectedDirectionToTarget = SampleMath::Vec3FNormalize(projectedDirectionToTarget);
projectedCameraLookAt = SampleMath::Vec3FNormalize(projectedCameraLookAt);

// find the dot and cross products of the normalized vectors
float dot = SampleMath::Vec3FDot(projectedDirectionToTarget, projectedCameraLookAt);
QCAR::Vec3F cross = SampleMath::Vec3FCross(projectedDirectionToTarget, projectedCameraLookAt);

// the angle between two vectors is the acos of the dot product
float angle = acos(dot);

// acos returns an angle in radians, convert to degrees
angle *= 180.0f / M_PI;

// our angle is now between 0 and 180, use the cross product to make it between 0 and 360
if (cross.data[2] < 0)
angle = 360.0f - angle;

LOG("angle: %f", angle);
```

Note that this gets you an angle between 0 and 360, with 0 being 12 o'clock in your terms. This is just to give you a starting point on the sort of math involved, you'll have to adapt it to your needs!

- Kim