Jump to content
  • Advertisement
Sign in to follow this  

Quaternions and multiple rotations

This topic is 609 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



If I want to combine quaternions in one transform, what's the proper way?

In the code below, I have a  point at a location, and I want to concatenate another rotation given an axis angle.

The if (1) etc. shows some possible ways.

I'm not getting the result I want, and perhaps I'm doing this incorrectly.


Thanks for any help!


void TransformPoint(Quaternion<double> & currentPose, double angleInDegreesForSegment,double axis, double P1[3]) { Quaternion<double> transformQ;  transformQ.SetRotationAngleAndAxis(RadiansFromDegrees(angleInDegreesForSegment), axis);  Quaternion<double> transformConjugate = transformQ.Conjugated(); Quaternion<double> P1q(0, P1[0], P1[1], P1[2]);
if (1)
    // Is it just this?
     Quaternion<double> P1R =  currentPose * transformQ * P1q * transformConjugate;     P1[0] = P1R.getX();     P1[1] = P1R.getY();     P1[2] = P1R.getZ();
 // Or ?
     Quaternion<double> currentConjugate = currentPose.Conjugated();

     Quaternion<double> P1R =  currentPose * transformQ * P1q * transformConjugate * currentConjugate;
    P1[0] = P1R.getX();
    P1[1] = P1R.getY();
    P1[2] = P1R.getZ();
​ }





Share this post

Link to post
Share on other sites
Write your axis+angle rotation as another quaternion. Composition of rotations corresponds to quaternion multiplication. That's all there is to it. You have to be careful to multiply the quaternions in the right order, because quaternion multiplication is not commutative.

Share this post

Link to post
Share on other sites

I hope the following example helps.


Define ref_joint_rotation as a constant reference joint rotation. ref_joint_rotation transforms vectors defined in joint frame to vectors in parent joint frame at pose configuration. Now you want to define the current reference joint rotation cur_joint_rotation as the reference joint rotation plus a rotation about 90 degrees about the z axis relative to the parent frame. That's how you would do this:

Vector3 axis
axis.Set(0.0f, 0.0f, 1.0f);
float angle = 0.5f * PI;

Quaternion joint_rotation;
joint_rotation.SetAxisAngle(axis, angle);

cur_joint_rotation = joint_rotation * ref_joint_rotation;

cur_joint_rotation rotates vectors in child frame to vectors in parent frame at the current configuration. Here the quaternion multiplication is defined in the original form. That is, a rotation by ref_joint_rotation followed by a rotation by joint_rotation.

Share this post

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

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!