Followers 0

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

## 1 post in this topic

[color=#000000][font=Arial,]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)[/font][/color]
[color=#000000][font=Arial,]I need to calculate azimuth, elevation of objects relatively to the cam view direction & plane.[/font][/color]

[color=#000000][font=Arial,][b]First question[/b]
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.[/font][/color]

[color=#000000][font=Arial,][b]Second question, the calculation.[/b]
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 :[url="http://fr.wikipedia.org/wiki/Quaternions_et_rotation_dans_l%27espace"]http://fr.wikipedia....ns_l&#39;espace[/url])[/font][/color]
[color=#000000][font=Arial,]Then, I have a vector result and I take X & Z component and calculate the atan2.[/font][/color]
[color=#000000][font=Arial,]Does it seem right ?[/font][/color]
[color=#000000][font=Arial,]any leads or explanation would help me a lot in my struggle[/font][/color] Edited by gluontronic
0

##### Share on other sites
#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).
0

## Create an account

Register a new account