diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2016-07-21 14:26:44 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2016-07-23 11:05:33 +0200 |
commit | b6ae6dcbb8ffc3dda16a2004c5fb98ea18890833 (patch) | |
tree | 6c995246eeeb1409932dfc02e9a4d308bcda5f5b | |
parent | 6a0ead2849c9e0dc3bbefeecf3e36d4f187624ae (diff) |
pose-widget: use common code for euler -> rmat
-rw-r--r-- | pose-widget/glwidget.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/pose-widget/glwidget.cpp b/pose-widget/glwidget.cpp index b9aec303..d8b451ef 100644 --- a/pose-widget/glwidget.cpp +++ b/pose-widget/glwidget.cpp @@ -47,18 +47,17 @@ void GLWidget::rotateBy(float xAngle, float yAngle, float zAngle, float x, float using std::sin; using std::cos; - float c1 = cos(yAngle / 57.295781f); - float s1 = sin(yAngle / 57.295781f); - float c2 = cos(xAngle / 57.295781f); - float s2 = sin(xAngle / 57.295781f); - float c3 = cos(zAngle / 57.295781f); - float s3 = sin(zAngle / 57.295781f); - - rotation = rmat(c2*c3, -c2*s3, s2, - c1*s3+c3*s1*s2, c1*c3-s1*s2*s3, -c2*s1, - s1*s3-c1*c3*s2, c3*s1+c1*s2*s3, c1*c2); + static constexpr num d2r = float(OPENTRACK_PI / 180); + translation = vec3(x, y, z); + euler::euler_t euler(-zAngle * d2r, xAngle * d2r, yAngle * d2r); + euler::rmat r = euler::euler_to_rmat(euler); + + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) + rotation(i, j) = num(r(i, j)); + update(); } |