在6DOF中的四元数相机表示 - 防止固有滚动 [英] Quaternion Camera Representation in 6DOF - fending off inherent rolling

查看:306
本文介绍了在6DOF中的四元数相机表示 - 防止固有滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

第一个问题,虽然我已经在这里很多次通过谷歌。我已经阅读了很多关于使用四元数表示旋转以及找到有类似问题的人的话题。我还没有找到一个好的解决方案,或一个我可以理解..所以我给了一个镜头,问一个明确的问题,以产生坚实的答案。

first question on SO although I've been here many times through Google. I have read quite a lot on the topic of using quaternions to represent rotation as well as finding people who have similar problems. I have yet to find a good solution, or one that I could understand.. so I'm giving a shot at asking a clear enough question to generate solid answers.

我目前使用四元数(具体来说,Qt 4.7四元数/ C ++)来表示我的相机的方向。在程序的每一步,我检查鼠标移动,并做一个fromAxisAndAngle(xaxis,x_mouse_movement)和fromAxisAndAngle(yaxis,y_mouse_movement)。我把这两个四元数并乘以它们(yaxis * xaxis)。对于初始化,我有一个单位四元数(w,x,y,z - > 1,0,0,0)乘以。我继续积累旋转这些从xisAndAngle乘法与当前方向。这产生一个卷,被称为李集团问题(我认为),如果你应用俯仰和偏航连续,你可以生成一个纯卷,这是我在我目前的实现(这是正确的我的程序,直到

I am currently using a quaternion (specifically, a Qt 4.7 quaternion/C++) to represent the orientation of my camera. At each step of the program I check for mouse movement and do a fromAxisAndAngle(xaxis, x_mouse_movement) and fromAxisAndAngle(yaxis, y_mouse_movement). I take these two quaternions and multiply them (yaxis * xaxis). For the initialization I have a unit quaternion (w,x,y,z -> 1,0,0,0) to multiply with. I keep accumulating the rotation over these fromAxisAndAngle multiplications with the current orientation. This produces a roll, known as the Lie Group Problem (I think) that if you apply pitch and yaw continuously you can generate a pure roll, and this is what I have in my current implementation (which is correct for my procedure as far as I can tell).

我已经实现了另一种方法,其中俯仰,偏航,滚动增加,四元数是从这些值每次从头开始由AxisAndAngle构建的。这产生正确的FPS型相机,但它遭受万向节锁。我的目标是保持纯四元数表示,同时消除(或补偿)仅由音高和雅司产生的滚动效果,所以我可以使用这个一般的6DOF相机作为FPS相机或太空船风格的相机。我正在寻找建议(特定例程)来纠正这个卷,或者一个替代表示,可以满足我的需要。对不起,墙上的文字,但我想要很清楚。感谢您的时间和快乐的黑客!

I have implemented another method where pitch,yaw,roll are incremented and the quaternion is built fromAxisAndAngle from scratch each time from these values. This produces a correct FPS style camera, but it suffers from gimbal lock. My goal is to keep the pure quaternion representation, while eliminating (or compensating for) the rolling effect produced from only pitches and yaws so I can use this general 6DOF camera as an FPS camera or a space ship style camera. I'm looking for suggestions (specific routines) for correcting this roll, or an alternative representation that can fit my needs. Sorry for the wall of text, but I wanted to be very clear. Thanks for your time and happy hacking!

推荐答案

这不是完全清楚你想要完成。请考虑:

It's not completely clear what you're trying to accomplish. Consider:


  1. 从标准方向开始(+ x向右,+ y向上,-z向前)

  2. 向下俯仰90°。 (-z向上,-y向前)

  3. 向右偏转90°。 (+ y是右,+ x是向前)

  4. 向上90度。 (-x向上,-z向前)

  5. 您现在正面向标准前进,但向左滚动90°。

  1. Begin in the canonical orientation (+x is right, +y is up, -z is forward)
  2. Pitch down by 90°. (-z is up, -y is forward)
  3. Yaw right by 90°. (+y is right, +x is forward)
  4. Pitch up 90°. (-x is up, -z is forward)
  5. You are now facing the canonical forward again, but rolled 90° to the left.

你想要改变什么?这是正常的行为,如果你总是定义俯仰和偏航相对于摄像机/身体的参考帧。如果相反,你想要偏航总是绕着世界的y轴和俯仰绕着摄像机/身体的x轴旋转(这样摄像机的x轴总是平行于地平面)那么,如果你向下俯仰90°,偏航运动将在视觉上看起来是滚动(你向下看,转成一个圆圈)。保持该属性的四元数将总是具有零的z分量。你可以简单地在你的四元数上强制使用这个约束(确保总是重新规范化)。

What do you want to happen instead? This is normal behavior if you always define pitch and yaw to be with respect to the camera/body frame of reference. If, instead, you want 'yaw' to always rotate around the world's y-axis and 'pitch' to always rotate around the camera/body's x-axis (so that the camera's x-axis is always parallel to the ground plane), then, if you were pitched down by 90°, the yaw movement would visually appear to be roll (you're looking down and turning in a circle). A quaternion that maintains that property will always have a 'z' component of zero. You could simply enforce that constraint on your quaternion (being sure to always re-normalize).

但是,你单独记录俯仰和偏航的方法应该适用于这种情况。如果你只使用两个轴,万向节锁不是一个问题。你只需要确保你应用俯仰,然后偏航。

However, your method of simply keeping track of pitch and yaw separately should work fine for that case. Gimbal lock isn't a problem if you're only using two axes in the first place. You just need to be sure that you apply the pitch and then the yaw.

这篇关于在6DOF中的四元数相机表示 - 防止固有滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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