How to interpolate rotations?

后端 未结 4 1560
悲哀的现实
悲哀的现实 2021-02-14 15:29

I have two vectors describing rotations; a start rotation A and a target rotation B. How would I best go about interpolating A by a factor F to approach B?

Using a simpl

4条回答
  •  无人及你
    2021-02-14 16:29

    A simple LERP (and renormalizing) only works fine when the vectors are very close together, but will result in unwanted results when the vectors are further apart.

    There are two options:

    Simple cross-products:

    Determine the axis n that is orthogonal to both A and B using a cross product (take care when the vectors are aligned) and calculate the angle a between A and B using a dot product. Now you can simply approach B by letting a go from 0 to a (this will be aNew and applying the rotation of aNew about axis n on A.

    Quaternions:

    Calculate the quaternion q that moves A to B, and interpolate q with the identity quaternion I using SLERP. The resulting quaternion qNew can then be applied on A.

提交回复
热议问题