How to calculate Azimuth & Elevation of objects relative to camera using cam quaternion …?

依然范特西╮ 提交于 2019-12-24 09:42:33

问题


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 put the object in center of my view, f I rotate the cam, translate it, 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 taken the resulting coordinates and make the sandwich product with the quaternion and its conjugate. (I followed this for the pseudo code : http://fr.wikipedia.org/wiki/Quaternions_et_rotation_dans_l'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


回答1:


The second calculation you've described seems pretty close to correct, but with a couple of underlying assumptions that you should verify. I'll discuss those in a moment. Your first question, however, doesn't make sense.

Both rotation and translation will almost always change the azimuth value. If you're looking straight at the object, azimuth==0. If you then rotate 90° to the left, the azimuth has clearly also changed by 90°. If you then take a step (of length x) forward, your azimuth has just gained an additional atan(x/d) degrees (where d is the original distance that the object was ahead of you).

As for finding the azimuth and elevation, your computation depends on assumptions about the default orientation of the world. I.e., if your camera coordinates are [0,0,0] the quaternion is the identity rotation, then what direction is the camera facing and what direction is up? Typically, 'up' is +y and forward is -z. If that's the case, then you'll compute thus:

p = q'*(obj-cam)*q
az = atan2(p.x,-p.z)
el = asin(p.y/sqrt(p.x*p.x + p.y*p.y + p.z*p.z))

Where q' is the quaternion conjugate/inverse (just negate q.w) and * is quaternion multiplication (the w component of the vector is set to zero).



来源:https://stackoverflow.com/questions/11165863/how-to-calculate-azimuth-elevation-of-objects-relative-to-camera-using-cam-qua

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!