First off, this is not a duplicate. All other seemingly related questions ask for the quaternion representing rotation between directions of 2 vectors, i.e. the solutions do not take into account norms of these 2 vectors.
Here is what I want. Imagine that I have non-unit vectors a = (0, 0, 2)
and b = (3, 1, 2)
. Following the original Hamilton's definition of quaternion q = a / b
(this definition is symbolic, since of course you cannot divide vectors). Refer to Wikipedia for this concept. From that I can infer (maybe it's naive) that somehow I can find such q
that q * b = a
.
In other words, given a
and b
I want to find a quaternion q
which when multiplied by b
will give me a
. Please, pay attention to the fact that I'm not interested in plain rotating (unitary) quaternion which would simply rotate b
into direction of a
. In fact, in addition to rotation, I want norm of b
to be scaled to the norm of a
as well.
Yes, I know that I could do it in two stages: rotating b
with standard unitary quaternion approach and then manually scaling the rotated b
to the norm of a
which would of course involve additional square roots (which is what I'm trying to avoid here). In fact, I want a computationally efficient composition of these 2 operations, and I feel like it's achievable, but the information is not widespread since it does not seem to be conventional use case.
Maybe I'm wrong. Please, share your experiences. Thank you.
Why not math.stackexchange.com?
Because I'm not interested in thorough mathematical derivation or explanation. My concern is computationally efficient algorithm for construction of such quaternion. Nevertheless, if such details will be included in the answer, I'd really appreciate that and probably others who stumble across the same issue in future too.
For Close Voters:
Go ahead and close Finding quaternion representing the rotation from one vector to another as well.
Furthermore, I have tagged my question properly. My question belongs to these highly-populated tags which are part of StackOverflow. As a result, your reasons for close do not make any sense.