# I need help with interpolation of rotation

Could you help me with interpolation of rotation? I have the rotation #1 and the rotation #2. I have to get the rotation #3 when I know the rotations #1 and #2. How can I get it? I can to get the rotation #2, when I know the rotations #1 and #3 using the slerp/nlerp, but what can I do in my case?
http://imgur.com/RMTyD3d
http://imgur.com/Q3QFXqg

What is rotation 3 in relation to 1 and 2? Double? 1.5x? Itâ€™s hard to tell what you are actually trying to do.

The rotation #3 is continued of rotation #2 from rotation #1

Continued by how much? How do you know?

What is it that you are actually trying to do?

I try to continue the rotation from the rotation #2 to the rotation, which is rotation #2 plus the different between the rotation #1 and the rotation #2.

No. I mean why do you want to do that?

Anyway, given that you donâ€™t seem to know how far you want to continue then any random rotation should be good enough I guessâ€¦ or just go all the way back to 1â€¦ thatâ€™s a continuation from 2 from 1.

I think Iâ€™m going to bow out of this thread until new information is provided. Talking in circles isnâ€™t something I have time for at the moment.

My real case:
I have the space ship which has rotation #1. When I receive from server the rotation #2 for rotating it, I have to animate from its rotation to rotation #2. When the ship rotated to rotation #2, I have to continue the rotating for the same direction until I will get the command stop from my server.

I havenâ€™t tried it recently but what happens if you pass 1.1, 1.2, etc. to nlerp()? In theory the math might work ok.

Edit: else the issue comes back to what I was saying before that you donâ€™t know how much farther you want to continue in relation to the difference from 1 to 2.

When I last tried this method, it was working very weird and wrong. I will try to recheck it again. [quote=â€śpspeed, post:8, topic:36162â€ť]
Edit: else the issue comes back to what I was saying before that you donâ€™t know how much farther you want to continue in relation to the difference from 1 to 2.
[/quote]
Now Iâ€™m using this method:
I have the start rotation and the end rotation. I add the offset to both rotations every time, when my ship has rotated to the end rotation. After this I continue the rotation of ship using new the start rotation and the end rotation.
That code is method of getting offset:

``````final Quaternion diff = getBufferRotation();
diff.set(end);
diff.subtractLocal(start);

start.normalizeLocal();

end.normalizeLocal();
``````

This code works wrong from time to time

Yes, subtracting quaternions like that and expecting them to still be rotations doesnâ€™t make any sense mathematically.

If you want to know what the difference in rotation is between 2 and 1 then you have to do a change of basis. Itâ€™s similar to if you want to convert world rotation to local rotation in a parentâ€™s space.

Itâ€™s something like:
Quaternion delta = rotation2.mult(rotation1.inverse());

â€¦you can check if itâ€™s right because rotation1.mult(delta) should give you something nearly identical to rotation 2.

After that, rotation1.mult(delta) is like nlerp(1) and rotation1.mult(delta).mult(delta) is like nlerp(2) of your original rotations.

â€¦though I feel like ultimately you might regret this approach to client/server communication.

1 Like

I rechecked the option of using nlerp(), it is works fine. Thanks very much