Sunday, September 11, 2022
HomeGame Developmentunity - Compute the distinction between two quaternions and iterate with the...

unity – Compute the distinction between two quaternions and iterate with the distinction


Quaternion distinction:

 C = Quaternion.Inverse(B) * A;

Quaternion division by a scalar:

 C_fraction = Quaternion.Slerp(Quaternion.identification, C, 1f/steps);

Quaternion increment:

 for (int i = 0; i < steps; i++) {
     B = B * C_fraction;
 }

Although a extra idiomatic method to write this is able to be…

 for (int i = 0; i < steps; i++) {
     float progress = (i + 1) / (float)steps;
     interpolated = Quaternion.Slerp(begin, finish, progress);
 }

In the event you do not want each step to be precisely the identical, Lerp additionally works rather than Slerp, however is a bit of cheaper. It takes smaller steps at first and finish of the interpolation and greater steps within the center.

Notice that order issues, and expresses sequence of rotations, or which rotations must be carried out relative to the guardian/world axes (phrases on the left) or utilizing the thing’s native axes (phrases on the appropriate proper).

Writing C as I did above, it is a native house rotation that must be multiplied on the appropriate to have its meant impact: B * C == B * Inverse(B) * A == A.

Flipping the order of multiplication to C * B is not going to, normally, give me A. To get a distinction for left-multiplication like that (making use of C in guardian/world house), I might must outline C with A on the left too: C = A * Inverse(B)

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments