Can I interpolate rotation from two Quaternions created from Yaw/Pitch/roll?

空扰寡人 提交于 2019-12-10 12:49:14

问题


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?

回答1:


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.




回答2:


You can interpolate between quaternions. I once wrote a quaternion-based keyframe animation generator that generated frames for a rendering systems from a few specific points. I can't share the code because it's classified :-(

There was a paper in the SIGGRAPH proceedings sometime in the 80s about this very topic. The main advantage of quaternions is that there's no singularity like there is with Euler angles.

Ah, here's the reference:

Shoemaker, Ken “Animating Rotation with Quaternion Curves”, SIGGRAPH '85, San Francisco, Jul. 22-26, 1985, vol. 19, No. 3, 1985 ACM 0-89791-166-0/85/007/0245, pp. 245-254.




回答3:


Yes and no. Here's a good discussion: http://number-none.com/product/Understanding%20Slerp,%20Then%20Not%20Using%20It/

Note it doesn't really matter how you got the quaternions, the same rules apply.

Edit: I have used the source code presented in the paper on a number of projects and can vouch for it.



来源:https://stackoverflow.com/questions/1684594/can-i-interpolate-rotation-from-two-quaternions-created-from-yaw-pitch-roll

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!