diff options
author | mm0zct <the_cartographer@hotmail.com> | 2013-06-25 01:44:10 +0100 |
---|---|---|
committer | mm0zct <the_cartographer@hotmail.com> | 2013-06-25 01:44:10 +0100 |
commit | cdb407f7b789908e2fbe10e46462d45eced2625f (patch) | |
tree | 3eed20ca7a401767463f325ef15d6df54791eb03 | |
parent | 78704527b51e753014911cb002a2d6efda04f0be (diff) |
Fixed rotation.h
-rw-r--r-- | facetracknoir/facetracknoir.rc | 2 | ||||
-rw-r--r-- | facetracknoir/rotation.h | 29 |
2 files changed, 21 insertions, 10 deletions
diff --git a/facetracknoir/facetracknoir.rc b/facetracknoir/facetracknoir.rc index fcae12b3..655baa9d 100644 --- a/facetracknoir/facetracknoir.rc +++ b/facetracknoir/facetracknoir.rc @@ -1,2 +1,2 @@ -#include "resource.h"
+#include <windows.h>
IDI_ICON1 ICON "facetracknoir.ico"
diff --git a/facetracknoir/rotation.h b/facetracknoir/rotation.h index 1a4e705b..a1500969 100644 --- a/facetracknoir/rotation.h +++ b/facetracknoir/rotation.h @@ -10,7 +10,7 @@ #include <cmath>
// ----------------------------------------------------------------------------
class Rotation {
- friend Rotation operator*(const Rotation& A, const Rotation& B);
+
public:
Rotation() : a(1.0),b(0.0),c(0.0),d(0.0) {}
Rotation(double yaw, double pitch, double roll) { fromEuler(yaw, pitch, roll); }
@@ -38,12 +38,30 @@ public: d = cos_phi*cos_the*sin_psi - sin_phi*sin_the*cos_psi;
}
- void Rotation::toEuler(double& yaw, double& pitch, double& roll)
+ void toEuler(double& yaw, double& pitch, double& roll)
{
roll = atan2(2.0*(a*b + c*d), 1.0 - 2.0*(b*b + c*c));
pitch = asin(2.0*(a*c - b*d));
yaw = atan2(2.0*(a*d + b*c), 1.0 - 2.0*(c*c + d*d));
}
+
+/* const Rotation operator*(const Rotation& A, const Rotation& B)
+ {
+ return Rotation(A.a*B.a - A.b*B.b - A.c*B.c - A.d*B.d, // quaternion multiplication
+ A.a*B.b + A.b*B.a + A.c*B.d - A.d*B.c,
+ A.a*B.c - A.b*B.d + A.c*B.a + A.d*B.b,
+ A.a*B.d + A.b*B.c - A.c*B.b + A.d*B.a);
+ }*/
+
+
+ const Rotation operator*(const Rotation& B)
+ {
+ const Rotation& A = *this;
+ return Rotation(A.a*B.a - A.b*B.b - A.c*B.c - A.d*B.d, // quaternion multiplication
+ A.a*B.b + A.b*B.a + A.c*B.d - A.d*B.c,
+ A.a*B.c - A.b*B.d + A.c*B.a + A.d*B.b,
+ A.a*B.d + A.b*B.c - A.c*B.b + A.d*B.a);
+ }
protected:
double a,b,c,d; // quaternion coefficients
@@ -51,11 +69,4 @@ protected: -Rotation operator*(const Rotation& A, const Rotation& B)
-{
- return Rotation(A.a*B.a - A.b*B.b - A.c*B.c - A.d*B.d, // quaternion multiplication
- A.a*B.b + A.b*B.a + A.c*B.d - A.d*B.c,
- A.a*B.c - A.b*B.d + A.c*B.a + A.d*B.b,
- A.a*B.d + A.b*B.c - A.c*B.b + A.d*B.a);
-}
#endif //ROTATION_H
|