Camera rotation using quaternions

How do I specify the rotation of a camera using quaternions about an axis at a specified angle. I know how to rotate about individual axis, but what if I wanted the camera to rotate about all three i:e: u,v and n axis about the eye.
I am programming in C++ using OpenGL.

Who is Participating?
jadeccConnect With a Mentor Commented:

I wish I could claim that I completely understood quaternions. What I had to do was keep up with the values (in degrees) of the heading (u), pitch (v), and roll (n) of the camera.  Then I created a quaternion from each of these angles and used them to figure out the view and driection of the camera:

      //quaternions that represent rotation
      m_qHeading.CreateFromAxisAngle(0.0f, 1.0f, 0.0f, m_HeadingDegrees);
      m_qPitch.CreateFromAxisAngle(1.0f, 0.0f, 0.0f, m_PitchDegrees);
      m_qRoll.CreateFromAxisAngle(0.0f, 0.0f, 1.0f, m_RollDegrees);
      //combine pitch and heading and roll and put into quaternion q
      q = m_qPitch * m_qHeading * m_qRoll;
      // set our new perspective
      //get the y coord for our direction from the pitch quaternion
      m_qDirection.y = Matrix[9];
      ypitch = Matrix[9];
      //combine heading and pitch rotations to get the x and z coords for our direction
      q = m_qHeading * m_qPitch;
      m_qDirection.x = Matrix[8];
      m_qDirection.z = Matrix[10];      

For a better explanation than I can offer check this link:

I hope that helps you more than hinders you:-)
deol_bhaji - Did jadecc answer your question? Do you need more or different information?

deol_bhajiAuthor Commented:
Thank you Jadecc. The link you sent was quite helpful. I guess I need to study a bit more on quaternions first.
All Courses

From novice to tech pro — start learning today.