• Create Account

## Calculation of azimuth & elevation of objects relative to a camera

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

### #1gluontronic  Members

115
Like
0Likes
Like

Posted 23 June 2012 - 01:44 AM

I have a camera quaternion (a,b,c,d) and a cam position (camX, camY, camZ)
I have an object with 3d coordinates (x,y,z)

I need to calculate azimuth, elevation of objects relatively to the cam view direction & plane.

First question
If I keep the object in center of my view (I mean, if I aim at it with my cam), even If I rotate the cam, translate it keeping the object in the center, I should have the same azimuth value, right ??
I don't have that.

Second question, the calculation.
I'm doing (object coordinates - cam position), in order to translate the object to the cam.
I'm taking the resulting coordinates and make the sandwich product with the quaternion and its conjugate.
(I followed this for the pseudo code :http://fr.wikipedia....ns_l&#39;espace)

Then, I have a vector result and I take X & Z component and calculate the atan2.
Does it seem right ?
any leads or explanation would help me a lot in my struggle

Edited by gluontronic, 23 June 2012 - 01:44 AM.

julien
> my project

### #2eppo  Members

4601
Like
0Likes
Like

Posted 24 June 2012 - 03:11 PM

#1, That's right. The normalized "object position - camera position"-vector would always be identical to the camera's tangent-vector. Both altitude and azimuth would equal zero.

#2. Easiest way would be to transform the obj-cam-vector into camera space (multiply by the camera's viewmatrix / inverse of its transformation).
Then the azimuth is calculated as: acos(dot(vec, z-axis)), elevation: acos(dot(vec, y-axis).

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.