private void CalculateJitterTest()

in sensors/Tools/SensorExplorer/Scenario0_Testing.xaml.cs [1006:1072]


        private void CalculateJitterTest()
        {
            string str = string.Empty;
            int type = SensorType[pivotSensor.SelectedIndex];
            if (type == Sensor.ACCELEROMETER)
            {
                double[] maxDifference = new double[3];
                foreach (double[] array in dataList)
                {
                    maxDifference[0] = (maxDifference[0] > Math.Abs(array[0] - accelerometerInitialReading.AccelerationX)) ? maxDifference[0] : Math.Abs(array[0] - accelerometerInitialReading.AccelerationX);
                    maxDifference[1] = (maxDifference[1] > Math.Abs(array[1] - accelerometerInitialReading.AccelerationY)) ? maxDifference[1] : Math.Abs(array[1] - accelerometerInitialReading.AccelerationY);
                    maxDifference[2] = (maxDifference[2] > Math.Abs(array[2] - accelerometerInitialReading.AccelerationZ)) ? maxDifference[2] : Math.Abs(array[2] - accelerometerInitialReading.AccelerationZ);
                }
                str = Constants.SensorName[type] + " " + testType + " Test Result: \n" +
                      "--> Maximum difference in X: " + maxDifference[0] + " G\n" +
                      "--> Maximum difference in Y: " + maxDifference[1] + " G\n" +
                      "--> Maximum difference in Z: " + maxDifference[2] + " G\n";
            }
            else if (type == Sensor.GYROMETER)
            {
                double[] maxDifference = new double[3];
                foreach (double[] array in dataList)
                {
                    maxDifference[0] = (maxDifference[0] > Math.Abs(array[0] - gyrometerInitialReading.AngularVelocityX)) ? maxDifference[0] : Math.Abs(array[0] - gyrometerInitialReading.AngularVelocityX);
                    maxDifference[1] = (maxDifference[1] > Math.Abs(array[1] - gyrometerInitialReading.AngularVelocityY)) ? maxDifference[1] : Math.Abs(array[1] - gyrometerInitialReading.AngularVelocityY);
                    maxDifference[2] = (maxDifference[2] > Math.Abs(array[2] - gyrometerInitialReading.AngularVelocityZ)) ? maxDifference[2] : Math.Abs(array[2] - gyrometerInitialReading.AngularVelocityZ);
                }
                str = Constants.SensorName[type] + " " + testType + " Test Result: \n" +
                      "--> Maximum difference in X: " + maxDifference[0] + " Degrees/s\n" +
                      "--> Maximum difference in Y: " + maxDifference[1] + " Degrees/s\n" +
                      "--> Maximum difference in Z: " + maxDifference[2] + " Degrees/s\n";
            }
            else if (type == Sensor.GYROMETER)
            {
                double maxDifference = 0;
                foreach (double[] array in dataList)
                {
                    maxDifference = (maxDifference > Math.Abs(array[0] - lightSensorInitialReading.IlluminanceInLux)) ? maxDifference : Math.Abs(array[0] - lightSensorInitialReading.IlluminanceInLux);
                }
                str = Constants.SensorName[type] + " " + testType + " Test Result: " + maxDifference + " Lux\n";
            }
            else if (type == Sensor.ORIENTATIONSENSOR || type == Sensor.ORIENTATIONGEOMAGNETIC || type == Sensor.ORIENTATIONRELATIVE)
            {
                double[] maxDifference = new double[4];
                foreach (double[] array in dataList)
                {
                    maxDifference[0] = (maxDifference[0] > Math.Abs(array[0] - orientationSensorInitialReading.Quaternion.W)) ?
                        maxDifference[0] : Math.Abs(array[0] - orientationSensorInitialReading.Quaternion.W);
                    maxDifference[1] = (maxDifference[1] > Math.Abs(array[1] - orientationSensorInitialReading.Quaternion.X)) ?
                        maxDifference[1] : Math.Abs(array[1] - orientationSensorInitialReading.Quaternion.X);
                    maxDifference[2] = (maxDifference[2] > Math.Abs(array[2] - orientationSensorInitialReading.Quaternion.Y)) ?
                        maxDifference[2] : Math.Abs(array[2] - orientationSensorInitialReading.Quaternion.Y);
                    maxDifference[3] = (maxDifference[3] > Math.Abs(array[3] - orientationSensorInitialReading.Quaternion.Z)) ?
                        maxDifference[3] : Math.Abs(array[3] - orientationSensorInitialReading.Quaternion.Z);
                }
                str = Constants.SensorName[type] + " " + testType + " Test Result: \n" +
                      "--> Maximum difference in W: " + maxDifference[0] + " Degrees\n" +
                      "--> Maximum difference in X: " + maxDifference[1] + " Degrees\n" +
                      "--> Maximum difference in Y: " + maxDifference[2] + " Degrees\n" +
                      "--> Maximum difference in Z: " + maxDifference[3] + " Degrees \n\n";
            }

            rootPage.LoggingChannelView.LogMessage(str);
            hyperlink.NavigateUri = new Uri("https://aka.ms/sensorexplorerblog");
            run.Text = "https://aka.ms/sensorexplorerblog";
            instruction.Text = str + "For more information, please visit:";
        }