quat_mult.cpp 847 B

123456789101112131415161718192021222324252627
  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. // generated by autoexplicit.sh
  21. template void igl::quat_mult<double>(double const*, double const*, double*);
  22. // generated by autoexplicit.sh
  23. template void igl::quat_mult<float>(float const*, float const*, float*);
  24. #endif