Identify a quaternion that sends one vector to another

Firstly, this is not a duplicate. All other seemingly related questions are asked by the quaternion, which represents a rotation between the directions of two vectors, i.e. The solutions do not take into account the norms of these two vectors.

Here is what I want. Imagine that I have non-unit vectors a = (0, 0, 2) and b = (3, 1, 2) . Following the initial definition of the Hamilton quaternion q = a / b (this definition is symbolic, because, of course, you cannot divide vectors). See Wikipedia for this concept . From this I can conclude (perhaps naively) that somehow I can find q such that q * b = a .

In other words, given a and b , I want to find the quaternion q , which when multiplied by b will give me a . Please note that I am not interested in a simple rotating (unitary) quaternion, which simply rotates b in the direction of a . In fact, in addition to rotation, I want the norm b also scale to the norm a .

Yes, I know that I could do this in two stages: rotating b with the standard unitary quaternion approach, and then manually scaling the rotated b to the norm a , which, of course, would include additional square roots (which is what I am trying to avoid here) . In fact, I want a computationally efficient composition of these two operations, and I feel that this is achievable, but the information is not widespread, because it does not seem like a normal use case.

Maybe I'm wrong. Please share your experience. Thanks.

Why not math.stackexchange.com ?

Because I am not interested in a thorough mathematical derivation or explanation. My concern is a computationally efficient algorithm for constructing such a quaternion. However, if such details are included in the response, I would really appreciate it and possibly others who also stumbled upon the same problem in the future.

For closed voters:

Go ahead and close the search for a quaternion representing a rotation from one vector to another .

In addition, I correctly tagged my question. My question relates to these high-level tags that are part of StackOverflow. As a result, your reasons for closing make no sense.

+4
source share
1 answer

The answer to Daniel Fisher's comment is correct. It turns out that there are endless ways to build such a quaternion. The problem comes down to a linear system with three equations and four variables. It is limited (if we assume that we discard the [w] part of the result).

Perhaps I can clarify Fisher’s answer.

When you treat two vectors as quaternions and multiply them, you get their cross-product in the [x, y, z] part, and you get your negative point product in the [w] part:

  | 0| | 0| |-ax*bx-ay*by-az*bz| a*b=|ax|*|bx|=| ay*bz-az*by | |ay| |by| | az*bx-ax*bz | |az| |bz| | ax*by-ay*bx | 

When you leave-multiply the full quaternion with the vector, you get the same thing, but the [w] part scales the vector and adds it back to the cross-product:

  |qw| | 0| |-qx*bx-qy*by-qz*bz| q*b=|qx|*|bx|=| qy*bz-qz*by+qw*bx| |qy| |by| | qz*bx-qx*bz+qw*by| |qz| |bz| | qx*by-qy*bx+qw*bz| 

Recall that

 axb = |a||b|sin(Θ)n 

where n is the unit vector orthogonal to a and b . AND

 a . b = |a||b|cos(Θ) 

The quaternion conjugate of a vector is simply its negation.

So, if we look at the Fisher equation:

 a = q*b = |b|^{-2} * a * b' * b 

We can see that

 a*b' = | -dotP(a,-b)| |crossP(a,-b)| 

So,

 a*b'*b = | -dotP(crossP(a,-b),b) | | crossP(crossP(a,-b),b) - dotP(a,-b)b | 

The upper part ([w]) of this quaternion must be zero, since it is a point product between two orthogonal vectors. The lower part is a scaled version of a : nested cross-products create a vector that is orthogonal to both b and n and is the length |a|*|b|*|b| . Part of the point product adds to the projection of a on b (scaled by the square of length b ). This brings him closer to a . As soon as we divide the length of the square b , all that remains is a .

Now the question of whether this is really useful is different. It is not very useful to find a , since you need to start it. Also, the chances are good that q*c not going to do what you hope, but you must tell us what it is.

+1
source

Source: https://habr.com/ru/post/1491006/


All Articles