Overte C++ Documentation
DualQuaternion.h
1 //
2 // DualQuaternion.h
3 //
4 // Created by Anthony J. Thibault on Dec 13th 2017.
5 // Copyright (c) 2017 High Fidelity, Inc. All rights reserved.
6 //
7 // Distributed under the Apache License, Version 2.0.
8 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
9 //
10 
11 
12 #ifndef hifi_DualQuaternion
13 #define hifi_DualQuaternion
14 
15 #include <QtGlobal>
16 #include <QDebug>
17 #include <glm/glm.hpp>
18 #include <glm/gtc/quaternion.hpp>
19 
20 class DualQuaternion {
21 public:
22  DualQuaternion();
23  explicit DualQuaternion(const glm::mat4& m);
24  DualQuaternion(const glm::quat& real, const glm::quat& imag);
25  DualQuaternion(const glm::quat& rotation, const glm::vec3& translation);
26  DualQuaternion(const glm::vec4& real, const glm::vec4& imag);
27  DualQuaternion operator*(const DualQuaternion& rhs) const;
28  DualQuaternion operator*(float scalar) const;
29  DualQuaternion operator+(const DualQuaternion& rhs) const;
30 
31  const glm::quat& real() const { return _real; }
32  glm::quat& real() { return _real; }
33 
34  const glm::quat& dual() const { return _dual; }
35  glm::quat& dual() { return _dual; }
36 
37  glm::quat getRotation() const;
38  glm::vec3 getTranslation() const;
39 
40  glm::vec3 xformPoint(const glm::vec3& rhs) const;
41  glm::vec3 xformVector(const glm::vec3& rhs) const;
42 
43  DualQuaternion inverse() const;
44  DualQuaternion conjugate() const;
45  float length() const;
46  DualQuaternion normalize() const;
47  float dot(const DualQuaternion& rhs) const;
48  DualQuaternion operator-() const;
49 
50 protected:
51  friend QDebug operator<<(QDebug debug, const DualQuaternion& pose);
52  glm::quat _real;
53  glm::quat _dual;
54 };
55 
56 
57 inline QDebug operator<<(QDebug debug, const DualQuaternion& dq) {
58  debug << "DualQuaternion, real = (" << dq._real.x << dq._real.y << dq._real.z << dq._real.w << "), dual = (" << dq._dual.x << dq._dual.y << dq._dual.z << dq._dual.w << ")";
59  return debug;
60 }
61 
62 #endif