EulToQuat.m 616 B

1234567891011121314151617181920212223
  1. function quaterion = EulToQuat(Euler)
  2. % Convert from a 321 Euler rotation sequence specified in radians to a
  3. % Quaternion
  4. quaterion = zeros(4,1);
  5. Euler = Euler * 0.5;
  6. cosPhi = cos(Euler(1));
  7. sinPhi = sin(Euler(1));
  8. cosTheta = cos(Euler(2));
  9. sinTheta = sin(Euler(2));
  10. cosPsi = cos(Euler(3));
  11. sinPsi = sin(Euler(3));
  12. quaterion(1,1) = (cosPhi*cosTheta*cosPsi + sinPhi*sinTheta*sinPsi);
  13. quaterion(2,1) = (sinPhi*cosTheta*cosPsi - cosPhi*sinTheta*sinPsi);
  14. quaterion(3,1) = (cosPhi*sinTheta*cosPsi + sinPhi*cosTheta*sinPsi);
  15. quaterion(4,1) = (cosPhi*cosTheta*sinPsi - sinPhi*sinTheta*cosPsi);
  16. return;