如何从之前的两个数据包推断出新的四元数旋转?
我已经无计可施了!我正在致力于减少第一人称射击游戏中的延迟,现在只需添加一些外推法即可。 我可以推断位置;获取最后两个位置及其速度,然后将速度添加到现有位置(* 增量时间)。 但是,我不能对旋转做同样的事情。 默认情况下,角度是欧拉角,但我可以(并且确实)将它们转换为四元数,因为它们可能会受到万向节锁定的影响。 我如何从之前的两个方向推断出新的方向? 我在数据包、2 个数据包和当前方向之间有时间。
I'm at my wits end here! I'm working on lag-reduction in my First Person Shooter, and now it's just a case of adding some extrapolation.
I can extrapolate position; getting the last two positions and the velocity from them, then adding the velocity to the existing position (* delta time).
However, i cannot do the same for rotation.
By default, the angles are Euler, but i can (and do) convert them to quaternions as they can suffer gimball lock.
How would i extrapolate a new orientation from 2 previous orientations?
I have time between packets, 2 packets and current orientation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在这里找到了一个很好的答案:
http://answers.unity3d.com/questions/168779/extrapolating-quaternion -rotation.html
我根据我的需要调整了代码,它工作得很好!
对于两个四元数 qa、qb,这将使用相同的公式进行插值和外推。 t是插值/外推的量,从qa->qb的方式t为0.1=0.1,t=-1->q从 qa->qb 推断出整个步骤,等等。
我使用自写函数来允许在 opencv cv::Mat 中使用四元数/axisAngle,但我可能会选择 Eigen
I found a good answer here:
http://answers.unity3d.com/questions/168779/extrapolating-quaternion-rotation.html
I adapted the code to my needs and it works quite well!
For the two quaternions qa, qb, this will give you interpolation and extrapolation using the same formula. t is the amount of interpolation/extrapolation, t of 0.1 = 0.1 of the way from qa->qb, t = -1 -> extrapolate a whole step from qa->qb back, etc.
I used selfwritten functions to allow the use of quaternions/axisAngle with opencv cv::Mat but I would probably choose Eigen for that instead
如果将两个方向表示为向量,则它们的向量叉积将为您提供旋转轴,并且向量点积可用于查找旋转角度。
然后,您可以按照与计算标量速度相同的方式计算角速度,并使用它来计算围绕先前确定的轴的外推旋转。
If you represent the two orientations as vectors, the vector cross product of them will give you the axis of rotation and the vector dot product can be used to find the angle of rotation.
You can then calculate an angular velocity in the same way as you calculated the scalar velocity, and use it to calculate the extrapolated rotation around the axis determined earlier.