Translating a Quaternion

Nick Heiner picture Nick Heiner · Oct 21, 2010 · Viewed 7.6k times · Source

(perhaps this is better for a math Stack Exchange?)

I have a chain composed of bones. Each bone has a with a tip and tail. The following code computes where its tip will be, given a rotation, and sets the next link in the chain's position appropriately:

    // Quaternion is a hand-rolled class that works correctly (as far as I can tell.)
    Quaternion quat = new Quaternion(getRotationAngleDegrees(), getRotation());

    // figure out where the tip will be after applying the rotation
    Vector3f rotatedTip = quat.applyRotationTo(tip);

    // set the next bone's tail to be at this one's tip
    updateNextPosFrom(rotatedTip);

This works if the rotation is supposed to occur around the origin of the object's coordinate system. But what if I want the rotation to occur around some other arbitrary point in the object? I'm not sure how to translate the quaternion. What is the best way to do it?

(I'm using JOGL / OpenGL.)

Answer

Reed Copsey picture Reed Copsey · Oct 21, 2010

A quaternion is used specifically to handle a rotation factor, but does not include a translation at all.

Typically, in this situation, you'll want to apply a rotation to a point based on the "bone's" length, but centered at the origin. You can then translate post-rotation to the proper location in space.