Difference between the two quaternions

后端 未结 5 890
栀梦
栀梦 2020-12-28 16:59

Solved


I\'m making a 3D portal system in my engine (like Portal game). Each of the portals has its own orientation saved in a quaternion. To render the virtu

5条回答
  •  太阳男子
    2020-12-28 17:52

    No, you have to multiply two quaternions together to get the final quaternion you desire.

    Let's say that your first rotation is q1 and the second is q2. You want to apply them in that order.

    The resulting quaternion will be q2 * q1, which will represent your composite rotation (recall that quaternions use left-hand multiplication, so q2 is being applied to q1 by multiplying from the left)

    Reference

    For a brief tutorial on computing a single quaternion, refer to my previous stack overflow answer

    Edit:

    To clarify, you'd face a similar problem with rotation matrices and Euler angles. You define your transformations about X, Y, and Z, and then multiply them together to get the resulting transformation matrix (wiki). You have the same issue here. Rotation matrices and Quaternions are equivalent in most ways for representing rotations. Quaternions are preferred mostly because they're a bit easier to represent (and easier for addressing gimbal lock)

提交回复
热议问题