Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an existing quaternion (Java Quat4f). I would like to rotate this quaternion around an axis (i.e. 90 degrees around the x axis, 25 degrees around the y axis, 10 degrees around the z axis, 180 degrees around the y axis, etc.)

How can I rotate the existing quaternion around an axis?

Thank you!

share|improve this question
up vote 1 down vote accepted

To combine rotations, I believe you canjust multiply that quaternion with a quaternion for each of the other axis rotations you require.

For example, in this simple (extension) method I wrote, I get the final quaternion by combining 3 quaternions for X, Y and Z rotations.

    //Takes in angles in degrees
    //Useful wiki page: and
    public static Quaternion ToOrientation(this Vector3 vec)
        Quaternion xRot = new Quaternion(Math.DegreesToRadians(vec.x), Vector3.UNIT_X);
        Quaternion yRot = new Quaternion(Math.DegreesToRadians(vec.y), Vector3.UNIT_Y);
        Quaternion zRot = new Quaternion(Math.DegreesToRadians(vec.z), Vector3.UNIT_Z);
        return xRot * yRot * zRot;

I must admit my knowledge of quaternions is not amazing, so any expansions on this answer would be appreciated.

Good luck! :)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.