我可以从偏航/俯仰/滚动创建的两个四元数中插入旋转吗? [英] Can I interpolate rotation from two Quaternions created from Yaw/Pitch/roll?

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

问题描述

四元数适用于在它们之间插入旋转.到目前为止一切顺利.

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

如果我有一个网络游戏,将旋转转换为 vector3f 就足够了,还是应该使用四元数?为了让游戏更流畅,我可能需要在上次发送的轮播和当前轮播之间进行插值.

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?

推荐答案

是的,你可以.欧拉角的问题是万向节锁定,即某些方向最终会减少一个自由度.当你从欧拉角转换为四元数时,这个问题就解决了.您几乎可以将任何 3D 轴表示转换为四元数形式并返回,而不会丢失任何信息.矩阵必须是各向同性的(没有缩放或剪切),向量必须是单位长度.

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.

四元数之间的线性插值称为slerp.四元数之间的二次插值称为squad.由于四元数只是具有三个虚部的复数,因此适用于实数和向量的相同方程也适用于四元数.请记住在进行乘法、加法、对数和幂运算时使用正确的规则.想象一下,i、j 和 k 的虚部共同构成一个轴向量,而实部是一个尺度.

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天全站免登陆