如何计算方位和放大器;高程采用凸轮四元相对于摄像头的对象......? [英] How to calculate Azimuth & Elevation of objects relative to camera using cam quaternion ...?

查看:241
本文介绍了如何计算方位和放大器;高程采用凸轮四元相对于摄像头的对象......?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个摄像头四元数(A,B,C,D)和凸轮位置(CAMX,CAMY,camZ) 我有一个对象,具有三维坐标(X,Y,Z)

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.

第一个问题 如果我把对象在我看来中心,F I旋转凸轮,翻译它,我应该有相同的方位角值,右? 我没有说。

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.

第二个问题,计算。 我做对象坐标 - 凸轮的位置,以将对象转换为凸轮。 我所采取的所得的坐标,使三明治产物与四元和它的共轭。 (我跟着这为伪code: http://fr.wikipedia.org/wiki / Quaternions_et_rotation_dans_l'espace

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)

然后,我有一个向量的结果,我拍X&放大器; Z分量并计算ATAN2

Then, I have a vector result and I take X & Z component and calculate the atan2

它看起来对吗?

任何线索或解释将帮助我很多在我的斗争

any leads or explanation would help me a lot in my struggle

推荐答案

你所描述的第二个计算似乎pretty的接近正确,但有一对夫妇,你应该确认的基本假设。我将讨论那些在某一时刻。你的第一个问题,但是,没有任何意义。

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.

两个旋转和平移将几乎总是改变方位角值。如果你正在寻找直接在对象,方位== 0 。如果然后旋转90°到左,方位已经清楚地也改变90°。如果再退一步(长度 X )前进,你的方位刚刚获得了一个额外的反正切(X / D)度( D 是原来的距离,对象是在你前面)。

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).

对于寻找方位角和仰角,你的计算依赖于对世界的默认方向的假设。也就是说,如果你的相机坐标为[0,0,0]四元数为单位旋转,那么什么方向是朝向摄像头,什么方向呢?通常情况下,上是 + Y 和前锋 -z 。如果是这样的话,那么你会计算这样的:

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))

其中, Q'是四元数的共轭/逆(只是否定 QW )和 * 是四元数乘法(向量的是W 部分设置为零)。

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).

这篇关于如何计算方位和放大器;高程采用凸轮四元相对于摄像头的对象......?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆