Search code examples
cmathvectorquaternions

What exactly is the output quaternion of slerp?


I'm trying to implement SLERP (described by Ken Shoemake in "Animating Rotation with Quaternion Curves) I've read up on the topic on wikipedia (topic: quaternions, 1 and 2) and other sites and also searched stackoverflow about this problem. It seems like I understand the theory behind it, but oversee one small detail. I will use w for the scalar value of the quaternion

So initially I have two 3D vectors. Each vector has a representation in two coordinate systems (C and C'). My goal is to find a third representation of these vectors in the system "halfway" the initial two. So what I do is I find the rotation matrix, which transform the vectors from C to C', which seems to work out quite fine. My next step is to transform this matrix into a quaternion, which also works.

Now my issue is with the formula of slerp, which is:

slerp(q1, q2; u) = ((sin(1-u) * t)/ (sin t)) * q1 + (sin(ut)/sin t) * q2

(sorry can't upload images yet for a better representation: see source 1)

so I guess here u = 0.5, q1 is the vector I would like to rotate (with w=0) and q2 equals the quaternion I calculated previously. Theta is calculated from the dotproduct of the normalized vector and the (already) normalized quaternion.

So what I expect is that I get back a vector, rotated either from C to the third coordinate system or from C' to the third coordinate system.

My issue now is, that I don't see, how I will get a vector and not a quaternion. Meaning, how is it possible, that I will get a quaternion with (w=0), as by simply multiplying q2 with this factor won't set w to 0. Or is it something else I will get from this function?

What am I overseeing here?

Thanks for your help!


Solution

  • Seems like I figured it out. For someone with the same understanding problem:

    slerp simply interpolates between two orientations, meaning between two actual rotations. So in my case, q1 is the quaternion corresponding to the identity matrix (so [1, 0, 0, 0]). q2 is the rotation. theta is still 0.5. With the quaternion I get from this, I have to calculate the rotation with q^-1 v q. Where v is my vector I want to rotate. This can be calculated using the Hamilton product.