🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Quaternion patterns

Started by
1 comment, last by frob 2 years, 4 months ago

Say I've got quaternions A and B, and they are the same only in terms of magnitude; the individual component values are not the same.

Say I've got 10,000 such pairs.

Is there a way to somehow find a common rotation operation so that I can transform A into B without first knowing B? How would I go about trying to find such common transformations? I've tried comparing dot products and whatnot, but no pattern jumps out at me.

Advertisement

I'm not sure that makes sense, or at least, not to me.

It may feel pedantic, but just to be sure we're on the same page: When used in games, typically quaternions are normalized to a magnitude of 1, encoding an orientation. They encode a 3D orientation almost identically to the way you can encode a 2D direction with polar coordinates. The real part is the distance along the path, the imaginary parts are the 3D orientation path. Just like polar coordinates can go around a circle infinitely many times so they normalize it to within a single rotation, the same is true with quaternions that there are infinitely many 3D wraps so normalizing it limits it to a single time around. Each normalized quaternion encodes a unique orientation.

It seems you're asking to transform from orientation A into orientation B that you don't know. You have a large number of possible point B's, but don't have one selected.

How you could you possible know what direction to turn if you don't know what the ending direction is going to be?

How you get to a destination is entirely dependent on where you start. Travel east only works if you're to the west. Travel north only works if you're to the south. If I tell you to travel north but you're to the east, the directions won't work.

But for a solution once you DO know the source and the destination:

If you know A and B, the two common approaches are “lerp” and “slerp”, that is, linear interpolation and spherical linear interpolation. They're straightforward functions (although a lot of operations) that let you interpolate between two different values. Lerp is based on a line and gives equal steps. Slerp is based around a circle and naturally produces an ease/out effect, but each step is a different length.

Video of the two functions. Lerp moves smoothly on the linear metric, but appears rough on the start/end of the sphere. Slerp moves smoothly on the sphere, but is uneven on the linear metric.

Note that with either function you still need to know both A and B. You can't do as you wrote in your question, knowing only A and not knowing which of the B's (which destination) you are going to use. There must be both a source and a destination.

This topic is closed to new replies.

Advertisement