寻找表示从一个向量到另一个向量的旋转的四元数 [英] Finding quaternion representing the rotation from one vector to another

查看:491
本文介绍了寻找表示从一个向量到另一个向量的旋转的四元数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个向量u和v.是否可以找到表示从u到v旋转的四元数的方法?

I have two vectors u and v. Is there a way of finding a quaternion representing the rotation from u to v?

推荐答案

Quaternion q;
vector a = crossproduct(v1, v2);
q.xyz = a;
q.w = sqrt((v1.Length ^ 2) * (v2.Length ^ 2)) + dotproduct(v1, v2);

别忘了对q进行归一化.

Don't forget to normalize q.

理查德说没有唯一的旋转是正确的,但是上面的应该给出最短的弧度",这可能是您所需要的.

Richard is right about there not being a unique rotation, but the above should give the "shortest arc," which is probably what you need.

这篇关于寻找表示从一个向量到另一个向量的旋转的四元数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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