“Distance” (or angular magnitude) between two quaternions?

谁说我不能喝 提交于 2020-01-12 05:45:06

问题


I want to find the "distance" between two quaternions. By "distance" I mean a single float or int, not another quaternion (that would be the difference, i.e. inverse(q1)*q2). I guess you could call what I want "angular magnitude".

I need to apply more torque to a physics object the further it's rotated from its original angle.

I don't understand the maths involved in quaternions, so a code-based example would be most helpful. I've looked at several other questions but I don't believe any answer my question, or at least not in a way I understand it.


回答1:


Find the difference quaternion qd = inverse(q1)*q2).

Than find the angle between q1 and q2 by angle = 2 * atan2(qd.vec().length(), qd.w()) // NOTE: signed

The "angle" here, is the angle of rotation from q1 to q2 by shortest arc.




回答2:


Also you can use this lib function from pyquaternion. Quaternion.absolute_distance(q0, q1)



来源:https://stackoverflow.com/questions/23260939/distance-or-angular-magnitude-between-two-quaternions

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