am 24754c9f: Merge "don\'t attempt to normalize the rotation vector" into gingerbread
* commit '24754c9f94b1bd8b176456da82a6059b2e8ded0f': don't attempt to normalize the rotation vector
This commit is contained in:
@@ -114,10 +114,12 @@ bool RotationVectorSensor::process(sensors_event_t* outEvent,
|
|||||||
float qx = sqrtf( clamp( Hx - My - Az + 1) * 0.25f );
|
float qx = sqrtf( clamp( Hx - My - Az + 1) * 0.25f );
|
||||||
float qy = 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 );
|
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);
|
||||||
qx = copysignf(qx, Ay - Mz) * n;
|
qy = copysignf(qy, Hz - Ax);
|
||||||
qy = copysignf(qy, Hz - Ax) * n;
|
qz = copysignf(qz, Mx - Hy);
|
||||||
qz = copysignf(qz, Mx - Hy) * n;
|
|
||||||
|
// this quaternion is guaranteed to be normalized, by construction
|
||||||
|
// of the rotation matrix.
|
||||||
|
|
||||||
*outEvent = event;
|
*outEvent = event;
|
||||||
outEvent->data[0] = qx;
|
outEvent->data[0] = qx;
|
||||||
|
|||||||
Reference in New Issue
Block a user