Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7b6e4bd6 authored by Mathias Agopian's avatar Mathias Agopian
Browse files

fix [3452750] Issue 14634: SensorManager.getRotationMatrixFromVector gets NaN-Values [external]

make sure to not pass negative numbers to sqrt().

Change-Id: Ifd200c781ae8a94c8a3c600401b60f4cf2430be3
related-bug: 3452750
parent cfe89034
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1970,7 +1970,8 @@ public class SensorManager
        if (rotationVector.length == 4) {
            q0 = rotationVector[3];
        } else {
            q0 = (float)Math.sqrt(1 - q1*q1 - q2*q2 - q3*q3);
            q0 = 1 - q1*q1 - q2*q2 - q3*q3;
            q0 = (q0 > 0) ? (float)Math.sqrt(q0) : 0;
        }

        float sq_q1 = 2 * q1 * q1;