Converting a direction vector to a quaternion rotation

邮差的信 提交于 2019-12-03 12:13:34

A direction vector is not a defined rotation, it still has an infinite number of possible solutions. See there is no information for how to rotate around the axis. Two, vectors is possible as is a vector and a rotation (with a meaningful center) and in fact a fully defined matrix.

Because in your case the rotation is rather meaningless, just use the up vector for reference (that is unless your light is shining top down or vice-versa then you need another reference).

So take the cross product of your direction vector D and up vector U for the side vector S then cross D and S for a new Un. Then use D, Un, S as rows (or columns depending on how your calculation rule is set up) as a matrix. Matrix to quaternion is well known math.

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