'Eigen::Quaternion::FromTwoVectors(a, b) * a != b

I am trying to get the quaternion representing the rotation from unit vector a to unit vector b.

As a sanity check this quaternion should garantee this equality q * a = b. The Eigen function Quaterniond::FromTwoVector https://eigen.tuxfamily.org/dox/classEigen_1_1Quaternion.html doesn't seem to respect my intuition. You can check here https://godbolt.org/z/rrb3Ev9cf (for a = {0, 0, -1} and b = {-0.0082091040565241327, 0.15209511189816791, -0.89586970189502269}).

Am i missing something ? Is there some condition that a and b must verify for this to be true ?



Solution 1:[1]

A check with R:

> crossprod(c(-0.0082091040565241327, 0.15209511189816791, -0.89586970189502269))
          [,1]
[1,] 0.8257828

shows that your vector b is not a unit vector.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Stéphane Laurent