Guest User

Untitled

a guest
Apr 21st, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. MEulerRotation rotationAverage(const std::vector<MQuaternion>& values)
  2. {
  3. if (values.empty()) return MEulerRotation::identity;
  4. const MQuaternion sum = std::accumulate(values.begin(), values.end(), MQuaternion::identity,
  5. [](const MQuaternion& a, const MQuaternion& b)
  6. {
  7. return a + b.log();
  8. });
  9. const MQuaternion average(sum.x / values.size(), sum.y / values.size(), sum.z / values.size(), sum.w / values.size());
  10. return average.exp().asEulerRotation();
  11. }
Add Comment
Please, Sign In to add comment