Recently, I’m using the source to do rotation on my 3D models. However, a problem occurred when calling the function: RotationBetweenVectors, defined in Tutorial 17( link: http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-17-quaternions/). I want to rotate vector _from to vector _to using Quaternion method. Two vectors are defined as following and a quat between them is calculated.
vec3 _from(0, -0.150401f, 0.93125f), _to(-0.383022f, -0.413672f, 1.24691f);
quat _rot = RotationBetweenVectors(_from, _to);
vec3 _to1 = _rot * _from;
vec3 _to2 = _rot * _from * inverse(_rot);
then I use this quat _rot to multiply vector _from. Unluckly, the result _to1 and _to2 are neither equal to vector _to.
_rot gives {x=0.0775952041 y=-0.140000001 z=-0.0226106234 w=0.986847401}
_to1 gives {x=-0.264032304 y=-0.285160601 z=0.859544873 }
_to2 gives {x=-0.500465572 y=-0.390112638 z=0.697992325 }
I appreciate it if any friend could help me out this problem? Thanks very much!