• Advertisement
Sign in to follow this  

Question about slerping quaternions (insert joke here)

This topic is 4277 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Lets say I have two object Obj1 and Obj2 and I want the orientation of Obj1 to become the orientation of Obj2. Both objects have orientations represented as quaternions and in order for me to orient Obj1 I slerp its orientation using the orientation of Obj2 as the destination for the slerp. My question is, since slerp generates intermediate results between two orientations do I have to do something like (in pseudo code):
while Obj1->orien != Obj2->orien
     slerp(Obj->orien, Obj2->orien, t) // objects passed by reference 
loop

Share this post


Link to post
Share on other sites
Advertisement
The parameter t is an interpolant, not a time value. If you feed t=0 into slerp, you'll get Q1, if you feed t=1 in, you'll get Q2. Values of t in between 0 and 1 will give you a quaternion in between Q1 and Q2. Outside 0 and 1... not well-defined.

If you want to increment t from 0 to 1 using a timestep, you could do something like:

const kMaxSlerpTime
totalSlerpTime = 0

while Obj1->orien != Obj2->orien && totalSlerpTime < kMaxSlerpTime

totalSlerpTime = totalSlerpTime + dt
t = Clamp(totalSlerpTime/kMaxSlerpTime, 0, 1)
slerp(Obj1->orien, Obj2->orien, t)

loop


P.S. I may have misunderstood the question.

[Edited by - jvsquare on August 10, 2006 10:42:01 AM]

Share this post


Link to post
Share on other sites
Something that might affect your choice of algorithm is whether the target orientation can change while the other orientation is attempting to match it.

If not, you can simply slerp between the original orientation and the target orientation using the appropriate value of t. t should progress from 0 to 1, with the speed of progression depending on how quickly you want the first orientation to match the second.

Note that with this approach there's no need to test the orientations for equality; when t reaches 1, you will have reached your goal.

If the target orientation is also changing, a different approach may be required (perhaps you could clarify whether or not this is the case).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement