summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2011-03-09 16:54:21 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-03-09 16:54:21 -0800
commitb710a50ab6ca36b502f548e8551f620e98bbb1d8 (patch)
treed862eb5a1a1a36582a5d358d6c08fe57bb687564
parentc05d35db1c57de97888f16ed74718e4c676e4a9b (diff)
parent5f94c315a65569bf66d603227177ba3f5ba5acd4 (diff)
downloadframeworks_base-b710a50ab6ca36b502f548e8551f620e98bbb1d8.zip
frameworks_base-b710a50ab6ca36b502f548e8551f620e98bbb1d8.tar.gz
frameworks_base-b710a50ab6ca36b502f548e8551f620e98bbb1d8.tar.bz2
Merge "fix [3452750] Issue 14634: SensorManager.getRotationMatrixFromVector gets NaN-Values [external] [DO NOT MERGE]" into gingerbread
-rw-r--r--core/java/android/hardware/SensorManager.java3
1 files changed, 2 insertions, 1 deletions
diff --git a/core/java/android/hardware/SensorManager.java b/core/java/android/hardware/SensorManager.java
index cc82170..b1a9349 100644
--- a/core/java/android/hardware/SensorManager.java
+++ b/core/java/android/hardware/SensorManager.java
@@ -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;