The operations of adding, subtracting and dividing quaternions on a 3d model

I just delved into using quaternions in 3D game programming (yes, I know about matrices, and they are fine, but we always need to learn some new things), so we can rotate some object like this Pout = q*Pin*conjug(q) , where q is the quaternion, Pin is the object (let's say we use some structure where this class is defined for us), the class is Vector3, conjug(q) is the q-quaternion after its conjugation, and finally Pout is a new object Vector3, we obtained after the rotation of the original object Vector3 Pin at an angle alfa (or theta, irrespective of the Wow, what you like). In addition, I know that there is a way to combine rotations, for example: q_final = q2*q1 (this means that it rotates along alpha1, and then at angles alfa2). And finally, the point-product is the angle between two quaternions, say, a sphere. This is clear to me. My question will be about things like division, addition and subtraction.

My question is : Can someone tell me, please, what are they (division, addition, subtraction-operations into quaternions) representing in 3D programming? How will they affect the 3D model?

Thank you for your responses.

ps If you ( DarenW, bensiu, Dharmendra, Uwe Keim, Jennis ) can not understand this question, please leave this topic. Someone may have an answer. Thanks.

+4
source share
1 answer

As you know, quaternions are identified with 4x4 real matrices. This identification preserves the quaternion multiplication, scalar multiplication and addition (see http://en.wikipedia.org/wiki/Quaternion#Matrix_representations ). Thus, the transformation of two quaternions into 4x4 matrices, their addition and their transformation are similar to their simple addition. The same is true for multiplication.

Dividing a quaternion A by a quaternion B is nothing more than multiplying A by the multiplicative inverse of B. This is equivalent to the matrix form A times the inverse of the matrix form B.

Note that the rotation of a rigid body (without shift or scaling) is represented by quaternions of unit length . Thus, you can accumulate rotations by multiplying units. Adding in this case is not so useful.

Finally, the main reason we use quatrains in the chart is the interpolation of key frames (for example, Eberly 1999 ). That is, if we know the required rotations in k positions, we can interpolate the quaters, for example. with a spline, leading to a quaternion curve. Each value of C (t) is a single quaternion, therefore it represents an intermediate rotation. Interpolation of key frames is more difficult with homogeneous matrices, because not all 4x4 matrices are homogeneous transformations: the interpolation process can add scaling, shift, etc.

+11
source

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


All Articles