Mathematics for high-quality quaternion, equivalent to matrix transformation

I am interested in implementing a clean solution that provides an alternative to 4x4 matrices for 3D conversion. Quaternions provide the equivalent of rotation, but not translation. Therefore, in addition to the quaternion, you need an additional translation vector (tx, ty, tz). I always saw that he stated that you need 12 values ​​for the matrix representation and only 7 for the quaternion based representation.

I do not understand how to manipulate translation values.

Quaternion rotation is not a problem.

For the vector v, the x axis vector and angle a:

q = cos(a/2) + x sin(a/2) 

To rotate a vector:

 v' = qvq^-1 

With multiple rotations, you can apply transformations to the quaternion, and only when you have the final rotation, you must apply it to the data. This is why matrix transformation is so beautiful in 3D graphics systems.

So now, if it includes translation, what should I do?

This vector transformation:

 T = (tx,ty,tz) v' = qvq^-1 + T 

If I want to apply the rotation and translation operation to this, I will have to change T and q. What should be the result?

+4
source share
3 answers

Well, I don't know what comes from Adam, but I know that these are linear operations. Therefore, if you have one operation (rotation, translation) (q, T) and another (r, U), and you apply them in this order, the general transformation is:

 r(qvq^-1 + T)r^-1 + U 

Spread r over the material in the parens on the left:

 (rqvq^-1 + rT)r^-1 + U 

Then distribute r ^ -1 to the right:

 rqvq^-1r^-1 + rTr^-1 + U 

And rebuild a bit:

 = (rq)v((rq)^-1) + (rTr^-1 + U) 

Thus, this composition is equivalent to the only (rotate, translate) (rq, rTr ^ -1 + U). And if you can make 2 of them, you can make N of them.

Does this help at all, or did I misunderstand the question?

+7
source

In addition to Nemo's answer, if you really want the full mathematical construction to represent a turn along with the translation, you can use double quaternions, although mathematics can be a bit overkill, they got some nice properties. In fact, these are only two quaternions (real and double parts), which are interpreted in a special way. It's nice that the usual operations defined on them (multiplication, conjugation, qvq *, ...), you can simply calculate using solid state transformations in a mathematically pure way, for example, with ordinary quaternions for rotations.

Wikipedia article may not be so descriptive, but Ladislav Kavan uses them for skinning (where they really play their advantages over matrices), and in his article he gives a good explanation.

+2
source

A few quaternion questions you need to know about:

  • Reverse quaternion is much easier to calculate that you stick to single quaternions. The inverse unit quaternion is simply conjugate, which is trivial to calculate. The inverse common quaternion requires four multiplications, the square root and division: what you do not want to do if you need speed.

  • Converting a vector through a quaternion involves a few more multiplications and additions than transforming through a matrix. If you need to do the same transformation several times, you may want to save both the quaternion and the corresponding transformation matrix and use what is faster / more accurate, given the operation operation.

  • Single quaternions are a double coating of the SO (3) group. Cancel all quaternion elements and you will get the same transformation.

  • Left and right quaternions. There are two ways to transform the vector v with the quaternion q: qvq * and q * vq. These two schemes differ only in whether the unconjugated quaternion is located to the left of the vector (left quaternions) or to the right (right quaternions). Both representations are absolutely true. Choose one, but be careful that no matter which one you choose, someone else will use the other. This may exchange quaternions with some other package problematic (but not if you know that this ambiguity exists).

  • Transformation against rotation. This problem of transformation and rotation also occurs with 3x3 matrices. (I'm not talking about this 4x4 math parody that some people use.) Suppose you have a sheet of white graph paper and a transparent sheet with graphic lines printed on it. Align the two so that the graph lines overlap. Now turn the transparency. This physical rotation can be described mathematically in terms of a rotation matrix or a quaternion of rotation (or many other representations, there are many diagrams on SO (3)). Now imagine that there is a dot on the white sheet. You can read the position of this point in terms of the white coordinate system or in terms of the transparency coordinate system. Converting from white sheet coordinates to transparency coordinates is a transformation (not a rotation). Transformation and rotation are closely related concepts; one is the transposition (or conjugation) of the other.

+1
source

All Articles