quat_mult.cpp 633 B

1234567891011121314151617181920212223
  1. #include "quat_mult.h"
  2. #include <cassert>
  3. // http://www.antisphere.com/Wiki/tools:anttweakbar
  4. template <typename Q_type>
  5. IGL_INLINE void igl::quat_mult(
  6. const Q_type *q1,
  7. const Q_type *q2,
  8. Q_type *out)
  9. {
  10. // output can't be either of the inputs
  11. assert(q1 != out);
  12. assert(q2 != out);
  13. out[0] = q1[3]*q2[0] + q1[0]*q2[3] + q1[1]*q2[2] - q1[2]*q2[1];
  14. out[1] = q1[3]*q2[1] + q1[1]*q2[3] + q1[2]*q2[0] - q1[0]*q2[2];
  15. out[2] = q1[3]*q2[2] + q1[2]*q2[3] + q1[0]*q2[1] - q1[1]*q2[0];
  16. out[3] = q1[3]*q2[3] - (q1[0]*q2[0] + q1[1]*q2[1] + q1[2]*q2[2]);
  17. }
  18. #ifndef IGL_HEADER_ONLY
  19. // Explicit template specialization
  20. #endif