![]() |
|
quaternion lerp instead of slerp |
hribek
Member #10,549
January 2009
|
EDIT: sorry name of topic is bad.:-/ Lerp and Slerp should co-exist. FIXME: this is the right place to post this stuff WHY: reasons for why to use normalize(lerp(quaternion, quaternion)) over slerp(quaternion, quaterion):
WHY NOT:
HOW:
|
Elias
Member #358
May 2000
|
I don't understand what commutative means. Can you explain it a bit shorter and simpler than the papers do? Let's say, in my game I have a spaceship. It looks somewhere. Now I want it to look somewhere else. And I use slerp to interpolate between the two rotations. Would anything change if I use nlerp instead? If yes, how would it look different? Also, I don't quite get how your /// comments work - just use a standard diff format, everyone in the dev forum will be used to reading that -- |
hribek
Member #10,549
January 2009
|
Quote: I don't understand what commutative means. Commutativity means that it does not matter in which order you perform something. In case of nlerp You can imagine creating in-between rotations as addition of numbers. You can add them in any order. In case of rotations You can create working_rotation how You wish. Quote: Can you explain it a bit shorter and simpler than the papers do? Let's say, in my game I have a spaceship. It looks somewhere. Now I want it to look somewhere else. And I use slerp to interpolate between the two rotations. Would anything change if I use nlerp instead? If yes, how would it look different? You will just get extra FPS (because You get rid of some expensive goniometry - sin(),acos()). Ship won't rotate at the same speed. Difference is minimal (some pictures and text from guy who "popularized" it) AFAI understand when You animate something You can do that by just assigning weights (10 % walking, 30 % running, 60 % jumping) to bones (directions, quaternions) and You can nlerp between them. >> diff |
Elias
Member #358
May 2000
|
Quote: Commutativity means that it does not matter in which order you perform something. In case of nlerp You can imagine creating in-between rotations as addition of numbers. You can add them in any order. In case of rotations You can create working_rotation how You wish. Hm. I don't know enough about quaternions then I guess, would have to see actual example code using Allegro's slerp function, to see code which would not work with it but would work with nlerp. Quote: You will just get extra FPS (because You get rid of some expensive goniometry - sin(),acos()). Ship won't rotate at the same speed. Difference is minimal (some pictures and text from guy who "popularized" it)
I see. I think the correct solution is more important for us than a slight performance gain (which in a game you likely could not even measure). But if you use the quaternions in something like physics simulation, I'm sure a deviation by "only" 8 degrees would wreak havoc -- |
hribek
Member #10,549
January 2009
|
from gamedev, posted by haegarr Quote:
I like to make things complicated (1) "intra-track interpolation" is done to yield in an intermediate value between 2 samples on the same track Now, slerp has a constant speed over the arc, since in fact the angle is interpolated. That guarantees a smooth motion. However, when a keyframe is crossed, a sudden change is introduced into the motion. This is a fact as long as any linear interpolation is used (slerp, nlerp) since linear interpolations provide only continuity in location, not in speed (notice please that the constant speed of slerp is only on the arc segment, not when going to the next segment). Due to this you may decide that constant speed over the arc is questionable, and may go with the nlerp instead (which is easier to implement and faster in processing). The nlerp doesn't show constant speed, but it has the advantage of being commutative (the slerp isn't commutative). For case (1) commutativity plays no role, since you can ever interpolate "naturally" from the sample with the lower timestamp to the one with the greater timestamp, even if you would play the animation backwards. However, for case (2) commutativity plays a role: The overall animation will look different if you blend animation A with B or else animation B with A. In other words, if the blending depends on the order, you impose your artist to think about that, and you need to implement a guarantee to get always the prescibed order. Hence, IMHO nlerp would be the better way for case (2).
So it's not so easy after all So. It looks like it is handy to have both. One for getting the arc of rotation right (PHYSICS). Other to blend several animation (GFX). I must apologize again for confusing title of this thread. |
SiegeLord
Member #7,827
October 2006
![]() |
Both slerp and nlerp have tradeoffs, and it seems unwise to say that one is the more proper one. I don't think Allegro 4.9 has quaternions yet, though I guess they might be useful in the primitives addon, once (or if) it goes full 3d. In which case, I shall provide both functions. "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
|