Guest User

Quaternion Rotation Formulas

a guest
Mar 1st, 2012
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. void MKSCamera::roll(const float& angle)
  2. {
  3.     // Rotate around local Z axis
  4.     Vector zAxis = m_qCurrent * Vector(1,0,0);
  5.     rotate(zAxis, angle);
  6. }
  7.  
  8. //-----------------------------------------------------------------------
  9. void MKSCamera::yaw(const float& angle)
  10. {
  11.     Vector yAxis = m_qCurrent * Vector(0,0,1);
  12.     rotate(yAxis, angle);
  13. }
  14.  
  15. //-----------------------------------------------------------------------
  16. void MKSCamera::pitch(const float& angle)
  17. {
  18.     // Rotate around local X axis
  19.     Vector xAxis = m_qCurrent * Vector(0,1,0);
  20.     rotate(xAxis, angle);
  21. }
  22.  
  23. //-----------------------------------------------------------------------
  24. void MKSCamera::rotate(const Vector& axis, const float& angle)
  25. {
  26.     Quat q;
  27.     q.AxisAngle(axis, angle);
  28.     rotate(q);
  29. }
  30.  
  31. //-----------------------------------------------------------------------
  32. void MKSCamera::rotate(const Quat& q)
  33. {
  34.     // Note the order of the mult, i.e. q comes after
  35.     m_qCurrent = q * m_qCurrent;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment