Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MEulerRotation rotationAverage(const std::vector<MQuaternion>& values)
- {
- if (values.empty()) return MEulerRotation::identity;
- const MQuaternion sum = std::accumulate(values.begin(), values.end(), MQuaternion::identity,
- [](const MQuaternion& a, const MQuaternion& b)
- {
- return a + b.log();
- });
- const MQuaternion average(sum.x / values.size(), sum.y / values.size(), sum.z / values.size(), sum.w / values.size());
- return average.exp().asEulerRotation();
- }
Add Comment
Please, Sign In to add comment