]> git.tdb.fi Git - libs/gl.git/commitdiff
Fix euler angle calculation in Transform
authorMikko Rasa <tdb@tdb.fi>
Sun, 9 Feb 2020 22:07:37 +0000 (00:07 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 9 Feb 2020 22:07:37 +0000 (00:07 +0200)
source/transform.cpp

index 6862221ba496fb5626736169c80789883c58cb7d..b703a5b12e345863c03c533f782adcfa4e5b33be 100644 (file)
@@ -17,7 +17,7 @@ Transform Transform::from_matrix(const Matrix &matrix)
 
        trn.euler.z = Geometry::atan2<float>(matrix(1, 0), matrix(0, 0));
        Matrix m = Matrix::rotation(-trn.euler.z, Vector3(0.0f, 0.0f, 1.0f))*matrix;
-       trn.euler.y = Geometry::atan2<float>(m(2, 0), m(0, 0));
+       trn.euler.y = Geometry::atan2<float>(-m(2, 0), m(0, 0));
        m = Matrix::rotation(-trn.euler.y, Vector3(0.0f, 1.0f, 0.0f))*m;
        trn.euler.x = Geometry::atan2<float>(m(2, 1), m(1, 1));
        m = Matrix::rotation(-trn.euler.x, Vector3(1.0f, 0.0f, 0.0f))*m;