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

Commit 5f94c315 authored by Mathias Agopian's avatar Mathias Agopian
Browse files

fix [3452750] Issue 14634: SensorManager.getRotationMatrixFromVector gets...

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

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

Change-Id: Ia31f7ebb7b75c79b548e428c6084fa55031617d0
related-bug: 3452750
parent 241d8a84
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;