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? :slight_smile:
http://imgur.com/RMTyD3d
http://imgur.com/Q3QFXqg
Imgur

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 :slight_smile:

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. :slight_smile:

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. :slight_smile:[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.addLocal(diff);
start.normalizeLocal();

end.addLocal(diff);
end.normalizeLocal();

This code works wrong from time to time :frowning:

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 :slight_smile: