Producing Quaternion between vectors

Hello,
In the example below I compute a quaternion of rotation from U vector to V vector. After that, I create a new vector U2 that is initialized to U and then rotated by the quaternion. Thus U2 should be V, but that is not the case

Please let me know what I am doing wrong
thank you

Hi DavidP !

I guess it is because you create your Quaternion with the FromUnitVectorsToRef method but the vectors given in parameters are not normalized.

It seems to work fine with this single change (line 31):
BABYLON.Quaternion.FromUnitVectorsToRef(U.normalizeToNew(), V.normalizeToNew(), resQ);

Have a nice day !

3 Likes

Please note that if your purpose is to reach U2 to be V, then you will have to scale U2 by the V size.

2 Likes

You are spot on !!! :slight_smile:

@Amarth2Estel Thank you! That works