How does game engine take quaternion into calculation?

Transform matrix is a 4x4 matrix, and quaternion is only 1x4… how is everything happening behind the scene?

I’ve heard it said that quaternions are an entire field of specialization in the world of mathematics. I’ve come to accept that it’s a level of mathematical wizardry that I will never achieve. The Quaternion class is a godsend.

I believe that quaternion is somehow transformmed back into 4x4 matrix of rotation (rotMatrix) , and later take rotMatrix into calculation, but I am not so sure… I am curious about it,

Well, first up, things don’t necessarily have to be the same size to multiply them. Secondly, remember that where a quaternion stores only rotation a 4x4 matrix also stores position and scale data.

I can’t be more precise than that without going into the math, which I do recommend everyone works through for themselves at least once. You’ll rarely have to apply it manually yourself working in something like Unity, but having a solid grasp of how it all works - not just this, but matrix multiplication, the how and where various bits of data are represented, transformations between different representations and knowing the pros and cons of each - will better equip you figure out how to make stuff happen.

You can inspect the source code for Quaternion’s operators in MonoDevelop. They are indeed doing the equivalent math of using a rotation matrix.

public static Vector3 operator * (Quaternion rotation, Vector3 point)
{
    float num = rotation.x * 2f;
    float num2 = rotation.y * 2f;
    float num3 = rotation.z * 2f;
    float num4 = rotation.x * num;
    float num5 = rotation.y * num2;
    float num6 = rotation.z * num3;
    float num7 = rotation.x * num2;
    float num8 = rotation.x * num3;
    float num9 = rotation.y * num3;
    float num10 = rotation.w * num;
    float num11 = rotation.w * num2;
    float num12 = rotation.w * num3;
    Vector3 result;
    result.x = (1f - (num5 + num6)) * point.x + (num7 - num12) * point.y + (num8 + num11) * point.z;
    result.y = (num7 + num12) * point.x + (1f - (num4 + num6)) * point.y + (num9 - num10) * point.z;
    result.z = (num8 - num11) * point.x + (num9 + num10) * point.y + (1f - (num4 + num5)) * point.z;
    return result;
}

wow,thx…you are really powerful…