如何计算方位角&使用凸轮四元数相对于相机的物体高程......? [英] How to calculate Azimuth & Elevation of objects relative to camera using cam quaternion ...?

查看:24
本文介绍了如何计算方位角&使用凸轮四元数相对于相机的物体高程......?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个相机四元数 (a,b,c,d) 和一个凸轮位置 (camX, camY, camZ)我有一个具有 3d 坐标 (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.

第一个问题如果我把物体放在我的视野中心,如果我旋转凸轮,平移它,我应该有相同的方位角值,对吧??我没有那个.

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.

第二个问题,计算.我正在做对象坐标 - 凸轮位置,以便将对象转换为凸轮.我得到了结果坐标,并用四元数及其共轭制作了三明治产品.(我按照这个伪代码:http://fr.wikipedia.org/wiki/Quaternions_et_rotation_dans_l'空格)

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

推荐答案

您描述的第二个计算似乎非常接近正确,但是您应该验证几个基本假设.我稍后会讨论这些.然而,你的第一个问题没有意义.

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.

旋转和平移几乎总是会改变方位角值.如果您直视物体,azimuth==0.如果然后向左旋转 90°,方位角也明显改变了 90°.如果您然后向前迈出一步(长度为 x),您的方位角刚刚获得了额外的 atan(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],则四元数是恒等旋转,那么相机朝向哪个方向,哪个方向朝上?通常,'up' 是 +y,而 forward 是 -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天全站免登陆