summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2010-12-01 03:37:40 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2010-12-01 03:37:40 -0800
commitfb49440b998c977c6928f07bda6127284dee6616 (patch)
treed8a8e6ba0b907b740833b130bbf1844dd304aa91 /services
parentdacf543dfe521b420b16b4588b14ef9f3b113add (diff)
parente3895b6ff2eca41c7a1e764e88af0591cbffa560 (diff)
downloadframeworks_base-fb49440b998c977c6928f07bda6127284dee6616.zip
frameworks_base-fb49440b998c977c6928f07bda6127284dee6616.tar.gz
frameworks_base-fb49440b998c977c6928f07bda6127284dee6616.tar.bz2
am e3895b6f: am 24754c9f: Merge "don\'t attempt to normalize the rotation vector" into gingerbread
* commit 'e3895b6ff2eca41c7a1e764e88af0591cbffa560': don't attempt to normalize the rotation vector
Diffstat (limited to 'services')
-rw-r--r--services/sensorservice/RotationVectorSensor.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/services/sensorservice/RotationVectorSensor.cpp b/services/sensorservice/RotationVectorSensor.cpp
index 6f4b8be..eecf260 100644
--- a/services/sensorservice/RotationVectorSensor.cpp
+++ b/services/sensorservice/RotationVectorSensor.cpp
@@ -114,10 +114,12 @@ bool RotationVectorSensor::process(sensors_event_t* outEvent,
float qx = sqrtf( clamp( Hx - My - Az + 1) * 0.25f );
float qy = sqrtf( clamp(-Hx + My - Az + 1) * 0.25f );
float qz = sqrtf( clamp(-Hx - My + Az + 1) * 0.25f );
- const float n = 1.0f / (qw*qw + qx*qx + qy*qy + qz*qz);
- qx = copysignf(qx, Ay - Mz) * n;
- qy = copysignf(qy, Hz - Ax) * n;
- qz = copysignf(qz, Mx - Hy) * n;
+ qx = copysignf(qx, Ay - Mz);
+ qy = copysignf(qy, Hz - Ax);
+ qz = copysignf(qz, Mx - Hy);
+
+ // this quaternion is guaranteed to be normalized, by construction
+ // of the rotation matrix.
*outEvent = event;
outEvent->data[0] = qx;