我可以插值从偏航/俯仰/卷创建了两个四元数旋转? [英] Can I interpolate rotation from two Quaternions created from Yaw/Pitch/roll?

查看:209
本文介绍了我可以插值从偏航/俯仰/卷创建了两个四元数旋转?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

四元数有利于它们之间的内插旋转。到目前为止好。

如果我有一个网络游戏,将它足以转动传送作为vector3f或者我应该用一个四元数? 为了使游戏更流畅也许是我最后一次送转和当前之间进行插值。

不过,我可以插这是从偏航创建了两个四元数之间的转/俯仰/卷?

 四元一= Quaternion.FromYawPitchRoll(X1,Y1,Z1);

四元数B = Quaternion.FromYawPitchRoll(X2,Y2,Z2);

a.Interpolate(B,值); //将正确这项工作?
 

解决方案

当然可以。欧拉角度的问题是万向节锁定,某些方位结束与自由少了一个程度。当从欧拉角转换为四元数,该问题得以解决。您可以转换几乎所有的3D轴重新presentation到四元数形式和背部,没有丢失任何信息。矩阵必须是各向同性的(无刻度或剪切),以及向量必须是单位长度。

四元数之间的线性插值所谓的球面线性插值的。二次四元数之间的插值被称为的阵容的。由于四元数只是复数三个虚部,对实数与向量的工作,同样的公式适用于四元。只记得做乘法,加法,日志和指数时使用了正确的规则。它可以帮助想象的虚部分(i),j和k一起形成轴矢量,而真正的部分是一个尺度。

Quaternions are good for interpolate rotations between them. so far so good.

If I have a networking game, will it suffice to transfer the rotation as vector3f or should I use a quaternion? To make the game smoother I may have to interpolate between the last sent rotation and the current one.

But can I interpolate rotations between two Quaternions which were created from Yaw/Pitch/Roll?

Quaternion a = Quaternion.FromYawPitchRoll(x1,y1,z1);

Quaternion b = Quaternion.FromYawPitchRoll(x2,y2,z2);

a.Interpolate(b, value); // will this work correctly?

解决方案

Yes you can. The problem with Euler angles is gimbal lock, that some orientations ends up with one less degree of freedom. When you convert from Euler angles to a quaternion, that problem is solved. You can convert almost any 3D-axis representation into quaternion form and back, without any loss of information. Matrices must be isotropic (no scale or shearing), and vectors must be of unit length.

Linear interpolation between quaternions is called slerp. Quadratic interpolation between quaternions is called squad. Since quaternions are just complex numbers with three imaginary parts, the same equations that work on real numbers and vectors applies to quaternions. Just remember to use the correct rules when doing multiplication, addition, log and exponentiation. It can help to imagine that the imaginary parts i,j and k together form an axis vector, while the real part is a scale.

这篇关于我可以插值从偏航/俯仰/卷创建了两个四元数旋转?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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