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

Commit e3895b6f authored by Mathias Agopian's avatar Mathias Agopian Committed by Android Git Automerger
Browse files

am 24754c9f: Merge "don\'t attempt to normalize the rotation vector" into gingerbread

* commit '24754c9f':
  don't attempt to normalize the rotation vector
parents 7fac762d 24754c9f
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -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;