diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2014-10-19 16:08:46 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2014-10-19 18:28:08 +0200 |
commit | dd87370ff2818ee3c3d67ba104405b85ee44daba (patch) | |
tree | d5ebdf22aaccd0e345ce7a7c2ecb7b7193ea0791 /opentrack/pose.hpp | |
parent | 7e2e341c45b86f76e08d74e056929ad76ff1a383 (diff) |
decruft more
Diffstat (limited to 'opentrack/pose.hpp')
-rw-r--r-- | opentrack/pose.hpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/opentrack/pose.hpp b/opentrack/pose.hpp new file mode 100644 index 00000000..41e984f5 --- /dev/null +++ b/opentrack/pose.hpp @@ -0,0 +1,44 @@ +#pragma once + +#include <utility> +#include <algorithm> +#include "./quat.hpp" +#include "./plugin-api.hpp" + +class Pose { +private: + static constexpr double pi = 3.141592653; + static constexpr double d2r = pi/180.0; + static constexpr double r2d = 180./pi; + + double axes[6]; +public: + Pose() : axes {0,0,0, 0,0,0 } {} + + inline operator double*() { return axes; } + inline operator const double*() const { return axes; } + + inline double& operator()(int i) { return axes[i]; } + inline double operator()(int i) const { return axes[i]; } + + Quat quat() const + { + return Quat(axes[Yaw]*d2r, axes[Pitch]*d2r, axes[Roll]*d2r); + } + + static Pose fromQuat(const Quat& q) + { + Pose ret; + q.to_euler_degrees(ret(Yaw), ret(Pitch), ret(Roll)); + return ret; + } + + Pose operator&(const Pose& B) const + { + const Quat q = quat() * B.quat().inv(); + Pose ret = fromQuat(q); + for (int i = TX; i < TX + 3; i++) + ret(i) = axes[i] - B.axes[i]; + return ret; + } +}; |