QuatDivide.m 378 B

12345678910111213141516
  1. function q_out = QuatDivide(qin1,qin2)
  2. q0 = qin1(1);
  3. q1 = qin1(2);
  4. q2 = qin1(3);
  5. q3 = qin1(4);
  6. r0 = qin2(1);
  7. r1 = qin2(2);
  8. r2 = qin2(3);
  9. r3 = qin2(4);
  10. q_out(1,1) = (qin2(1)*qin1(1) + qin2(2)*qin1(2) + qin2(3)*qin1(3) + qin2(4)*qin1(4));
  11. q_out(2,1) = (r0*q1 - r1*q0 - r2*q3 + r3*q2);
  12. q_out(3,1) = (r0*q2 + r1*q3 - r2*q0 - r3*q1);
  13. q_out(4,1) = (r0*q3 - r1*q2 + r2*q1 - r3*q0);