diff options
| author | Mathias Agopian <mathias@google.com> | 2010-11-30 14:03:43 -0800 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-11-30 14:03:43 -0800 |
| commit | 24754c9f94b1bd8b176456da82a6059b2e8ded0f (patch) | |
| tree | 9f88a55edec7aefd71d54df6e747f59444e0eab5 /services | |
| parent | d06010c3735332e4e4a090a82fd70695625bc875 (diff) | |
| parent | 5d45c33eb875b9c9d51c9364afa57a0be65adfa4 (diff) | |
| download | frameworks_base-24754c9f94b1bd8b176456da82a6059b2e8ded0f.zip frameworks_base-24754c9f94b1bd8b176456da82a6059b2e8ded0f.tar.gz frameworks_base-24754c9f94b1bd8b176456da82a6059b2e8ded0f.tar.bz2 | |
Merge "don't attempt to normalize the rotation vector" into gingerbread
Diffstat (limited to 'services')
| -rw-r--r-- | services/sensorservice/RotationVectorSensor.cpp | 10 |
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; |
