Quaternion and three axes

旧城冷巷雨未停 提交于 2019-12-23 13:08:35

问题


Given a quaternion q, and three 3D vectors (vx, vy, vz) which form coordinate axes, which can be oriented in arbitrary direction, but are all perpendicular to each other, thus forming a 3d space.

How can I check if the quaternion q is rotated to the same direction (or opposite direction) as some of the 3D vectors (vx, vy, vz)?


回答1:


If q = (w,x,y,z), where w is the "scalar part", and qv=(x,y,z) is the "vector part", then you can calculate the angle between qv and each of the basis vectors vx, vy, vz using the dot product.

cos(theta) = (qv dot vx) / ( |qv| * |vx|)

If cos(theta) is +1, the rotation axis of q is parallel to that basis vector.

cos(theta) = -1 implies that they are anti-parallel.



来源:https://stackoverflow.com/questions/3524433/quaternion-and-three-axes

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