void AccelerometerChanged(MotionVector vector)
        {
            string newRotationVector;

            if (vector.X <= vector.Y && vector.X <= vector.Z)
            {
                newRotationVector = "X";
            }
            else if (vector.Y <= vector.Z)
            {
                newRotationVector = "Y";
            }
            else
            {
                newRotationVector = "Z";
            }

            if (RotationVector == newRotationVector)
            {
                return;
            }
            else
            {
                RotationVector = newRotationVector;
                Reset();
            }
        }
        void GyroscopeChanged(MotionVector vector)
        {
            if (LatestCompassHeading == -1)
            {
                return;                             // Not started yet. Ignore.
            }
            var change = GetRotation(vector);

            var newHeading = GetNewHeading(change);
            var error      = GetHeadingError(newHeading);

            TotalRotation -= change;

            if (error >= TooMuchError)
            {
                newHeading = LatestCompassHeading;
            }
            else if (error > ToleratedError)
            {
                // Get it closer to the compass reading:

                if (IsAfter(newHeading, LatestCompassHeading))
                {
                    newHeading    -= COMPASS_APPROACH_SPEED;
                    TotalRotation -= COMPASS_APPROACH_SPEED;
                }
                else
                {
                    newHeading    += COMPASS_APPROACH_SPEED;
                    TotalRotation += COMPASS_APPROACH_SPEED;
                }

                if (newHeading > FULL_CIRCLE)
                {
                    newHeading = FULL_CIRCLE;
                }
                else if (newHeading < 0)
                {
                    newHeading = 0;
                }
            }

            SmoothHeading = newHeading;
            CurrentError  = error;

            OnChanged();
        }
        float GetRotation(MotionVector change)
        {
            double rotation;

            switch (RotationVector)
            {
            case "X": rotation = change.X; break;

            case "Y": rotation = change.Y; break;

            case "Z": rotation = change.Z; break;

            default: return(0f);
            }

            if (Math.Abs(rotation) < GyroscopeChangeSensitivity)
            {
                return(0f);
            }

            return((float)(rotation * (int)SensorDelay.Game * 0.001f).ToDegreeFromRadians());
        }