Skip to content

Commit b710a50

Browse files
pixelflingerAndroid (Google) Code Review
authored andcommitted
Merge "fix [3452750] Issue 14634: SensorManager.getRotationMatrixFromVector gets NaN-Values [external] [DO NOT MERGE]" into gingerbread
2 parents c05d35d + 5f94c31 commit b710a50

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

core/java/android/hardware/SensorManager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1970,7 +1970,8 @@ public static void getRotationMatrixFromVector(float[] R, float[] rotationVector
19701970
if (rotationVector.length == 4) {
19711971
q0 = rotationVector[3];
19721972
} else {
1973-
q0 = (float)Math.sqrt(1 - q1*q1 - q2*q2 - q3*q3);
1973+
q0 = 1 - q1*q1 - q2*q2 - q3*q3;
1974+
q0 = (q0 > 0) ? (float)Math.sqrt(q0) : 0;
19741975
}
19751976

19761977
float sq_q1 = 2 * q1 * q1;

0 commit comments

Comments
 (0)