Overte C++ Documentation
RotationAccumulator.h
1 //
2 // RotationAccumulator.h
3 //
4 // Copyright 2015 High Fidelity, Inc.
5 //
6 // Distributed under the Apache License, Version 2.0.
7 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
8 //
9 
10 #ifndef hifi_RotationAccumulator_h
11 #define hifi_RotationAccumulator_h
12 
13 #include <glm/gtc/quaternion.hpp>
14 
15 class RotationAccumulator {
16 public:
17  RotationAccumulator() : _rotationSum(0.0f, 0.0f, 0.0f, 0.0f), _numRotations(0), _isDirty(false) { }
18 
19  int size() const { return _numRotations; }
20 
23  void add(const glm::quat& rotation, float weight = 1.0f);
24 
25  glm::quat getAverage();
26 
28  bool isDirty() const { return _isDirty; }
29 
31  void clear();
32 
34  void clearAndClean();
35 
36 private:
37  glm::quat _rotationSum;
38  int _numRotations;
39  bool _isDirty;
40 };
41 
42 #endif // hifi_RotationAccumulator_h