/// <summary>
 /// This is the event handler for ReadingChanged events.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 async private void ReadingChanged(object sender, OrientationSensorReadingChangedEventArgs e)
 {
     await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         MainPage.SetReadingText(ScenarioOutput, e.Reading);
     });
 }
Exemplo n.º 2
0
        static void DataUpdated(object sender, OrientationSensorReadingChangedEventArgs e)
        {
            var reading = e.Reading;
            var data    = new OrientationSensorData(reading.Quaternion.X, reading.Quaternion.Y, reading.Quaternion.Z, reading.Quaternion.W);

            OnChanged(data);
        }
Exemplo n.º 3
0
        public async void NewQuan(OrientationSensor sender, OrientationSensorReadingChangedEventArgs args)
        {
            var reading = args == null?sender?.GetCurrentReading() : args.Reading;

            await this.dispatcher.RunAsync(
                CoreDispatcherPriority.Normal,
                () =>
            {
                this[QUANTIZATION] = reading == null
                                                 ? this[QUANTIZATION].New(0, 0, 0, 0)
                                                 : this[QUANTIZATION].New(
                    reading.Quaternion.X,
                    reading.Quaternion.Y,
                    reading.Quaternion.Z,
                    reading.Quaternion.W);
                if (this[QUANTIZATION].IsChanged)
                {
                    this.OnPropertyChanged(new PropertyChangedEventArgs("ItemsList"));
                    this.OnSensorUpdated?.Invoke(this[QUANTIZATION]);
                }
            });

            if (this.SensorSwitches.Q.HasValue && (this.SensorSwitches.Q.Value == 1 || this.SensorSwitches.Q.Value == 3))
            {
                this.SensorSwitches.Q = 0;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// This is the event handler for ReadingChanged events.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        //<SnippetReadingChangedCS>
        async private void ReadingChanged(object sender, OrientationSensorReadingChangedEventArgs e)
        {
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                OrientationSensorReading reading = e.Reading;

                // Quaternion values
                SensorQuaternion quaternion = reading.Quaternion;   // get a reference to the object to avoid re-creating it for each access
                ScenarioOutput_X.Text       = String.Format("{0,8:0.00000}", quaternion.X);
                ScenarioOutput_Y.Text       = String.Format("{0,8:0.00000}", quaternion.Y);
                ScenarioOutput_Z.Text       = String.Format("{0,8:0.00000}", quaternion.Z);
                ScenarioOutput_W.Text       = String.Format("{0,8:0.00000}", quaternion.W);

                // Rotation Matrix values
                SensorRotationMatrix rotationMatrix = reading.RotationMatrix;
                ScenarioOutput_M11.Text             = String.Format("{0,8:0.00000}", rotationMatrix.M11);
                ScenarioOutput_M12.Text             = String.Format("{0,8:0.00000}", rotationMatrix.M12);
                ScenarioOutput_M13.Text             = String.Format("{0,8:0.00000}", rotationMatrix.M13);
                ScenarioOutput_M21.Text             = String.Format("{0,8:0.00000}", rotationMatrix.M21);
                ScenarioOutput_M22.Text             = String.Format("{0,8:0.00000}", rotationMatrix.M22);
                ScenarioOutput_M23.Text             = String.Format("{0,8:0.00000}", rotationMatrix.M23);
                ScenarioOutput_M31.Text             = String.Format("{0,8:0.00000}", rotationMatrix.M31);
                ScenarioOutput_M32.Text             = String.Format("{0,8:0.00000}", rotationMatrix.M32);
                ScenarioOutput_M33.Text             = String.Format("{0,8:0.00000}", rotationMatrix.M33);
            });
        }
Exemplo n.º 5
0
 async void OrientationSensorChanged(OrientationSensor sender,
                                     OrientationSensorReadingChangedEventArgs args)
 {
     await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         ShowOrientation(args.Reading);
     });
 }
Exemplo n.º 6
0
        void OnReadingChanged(Sensor sender, OrientationSensorReadingChangedEventArgs args)
        {
            var handler = changed;

            if (handler != null)
            {
                var value = ConvertToMatrix(args.Reading);
                var e     = new OrientationEventArgs(value);
                handler.Invoke(this, e);
            }
        }
Exemplo n.º 7
0
        private async void Or_ReadingChanged(OrientationSensor sender, OrientationSensorReadingChangedEventArgs args)
        {
            if (myBool)
            {
                OrientationSensorReading reading = args.Reading;

                // Quaternion values
                SensorQuaternion q = reading.Quaternion;
                double           y = args.Reading.Quaternion.Y;
                if (y < 0)
                {
                    y = y + 2;
                }

                double pitch = y;
                //    pitch = pitch * 180 / Math.PI;
                if (yaw < 0)
                {
                    yaw += 360;
                }


                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    for (; lol.Children.Count > 1;)
                    {
                        lol.Children.RemoveAt(1);
                    }

                    foreach (PointerViewAR n in li2)
                    {
                        Image img            = new Image();
                        img.Name             = n.Id;
                        img.Width            = 250;
                        img.Height           = 250;
                        img.Source           = n.Media;
                        TranslateTransform t = new TranslateTransform();


                        t.X = angleDiff(n.Yaw, yaw) * stepW * 2;
                        t.Y = (n.Pitch - pitch) * stepH * 2;
                        Debug.WriteLine((n.Yaw - yaw).ToString() + ",");

                        img.RenderTransform = t;
                        img.IsTapEnabled    = true;
                        img.Tapped         += Img_Tapped;
                        lol.Children.Add(img);
                    }
                });
            }
        }
        /// <summary>
        /// This is the event handler for ReadingChanged events.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        async private void ReadingChanged(object sender, OrientationSensorReadingChangedEventArgs e)
        {
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                OrientationSensorReading reading = e.Reading;

                // Quaternion values
                SensorQuaternion quaternion = reading.Quaternion;   // get a reference to the object to avoid re-creating it for each access
                ScenarioOutput_X.Text       = String.Format("{0,8:0.00000}", quaternion.X);
                ScenarioOutput_Y.Text       = String.Format("{0,8:0.00000}", quaternion.Y);
                ScenarioOutput_Z.Text       = String.Format("{0,8:0.00000}", quaternion.Z);
                ScenarioOutput_W.Text       = String.Format("{0,8:0.00000}", quaternion.W);

                // Rotation Matrix values
                SensorRotationMatrix rotationMatrix = reading.RotationMatrix;
                ScenarioOutput_M11.Text             = String.Format("{0,8:0.00000}", rotationMatrix.M11);
                ScenarioOutput_M12.Text             = String.Format("{0,8:0.00000}", rotationMatrix.M12);
                ScenarioOutput_M13.Text             = String.Format("{0,8:0.00000}", rotationMatrix.M13);
                ScenarioOutput_M21.Text             = String.Format("{0,8:0.00000}", rotationMatrix.M21);
                ScenarioOutput_M22.Text             = String.Format("{0,8:0.00000}", rotationMatrix.M22);
                ScenarioOutput_M23.Text             = String.Format("{0,8:0.00000}", rotationMatrix.M23);
                ScenarioOutput_M31.Text             = String.Format("{0,8:0.00000}", rotationMatrix.M31);
                ScenarioOutput_M32.Text             = String.Format("{0,8:0.00000}", rotationMatrix.M32);
                ScenarioOutput_M33.Text             = String.Format("{0,8:0.00000}", rotationMatrix.M33);

                // Yaw accuracy
                switch (reading.YawAccuracy)
                {
                case MagnetometerAccuracy.Unknown:
                    ScenarioOutput_YawAccuracy.Text = "Unknown";
                    break;

                case MagnetometerAccuracy.Unreliable:
                    ScenarioOutput_YawAccuracy.Text = "Unreliable";
                    break;

                case MagnetometerAccuracy.Approximate:
                    ScenarioOutput_YawAccuracy.Text = "Approximate";
                    break;

                case MagnetometerAccuracy.High:
                    ScenarioOutput_YawAccuracy.Text = "High";
                    break;

                default:
                    ScenarioOutput_YawAccuracy.Text = "No data";
                    break;
                }
            });
        }
Exemplo n.º 9
0
        private void Sensor_ReadingChanged(OrientationSensor sender, OrientationSensorReadingChangedEventArgs args)
        {
            var c = Camera;

            if (c == null)
            {
                return;
            }

            var l = c.Transformation;
            var q = args.Reading.Quaternion;

            _controller.TransformationMatrix = InitialTransformation + TransformationMatrix.Create(q.X, q.Y, q.Z, q.W, 0, 0, 0);
        }
Exemplo n.º 10
0
        private async void Or_ReadingChanged(OrientationSensor sender, OrientationSensorReadingChangedEventArgs args)
        {
            if (myBool)
            {
                OrientationSensorReading reading = args.Reading;

                // Quaternion values
                SensorQuaternion q = reading.Quaternion;
                double           y = args.Reading.Quaternion.Y;
                if (y < 0)
                {
                    y = y + 2;
                }
                pitch = y;
                //    pitch = pitch * 180 / Math.PI;
                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    for (; lol.Children.Count > 6;)
                    {
                        lol.Children.RemoveAt(6);
                    }

                    foreach (PointerViewAR n in li2)
                    {
                        Image img            = new Image();
                        img.Name             = n.Id;
                        img.Width            = 250;
                        img.Height           = 250;
                        img.Source           = n.Media;// img.Stretch = Stretch.UniformToFill;
                        TranslateTransform t = new TranslateTransform();
                        double dis           = getDistance(n.lat, n.lon, pos.Coordinate.Latitude, pos.Coordinate.Longitude);
                        if (dis < 50)
                        //TODO: in prod write distance<20
                        {
                            // double ang = getangle(n.lat, n.lon, pos.Coordinate.Latitude, pos.Coordinate.Longitude);
                            t.X = angleDiff(n.Yaw, yaw) * stepW * 2;
                            t.Y = (n.Pitch - pitch) * stepH * 2;
                            img.RenderTransform = t;
                            img.IsTapEnabled    = true;
                            img.Tapped         += Img_Tapped;
                            lol.Children.Add(img);
                            Grid.SetRow(img, 1);
                        }
                    }
                });
            }
        }
Exemplo n.º 11
0
        private async void ReadingChanged(object sender, OrientationSensorReadingChangedEventArgs e)
        {
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                OrientationSensorReading reading = e.Reading;

                // Quaternion values
                txtQuaternionX.Text = String.Format("{0,8:0.00000}", reading.Quaternion.X);
                txtQuaternionY.Text = String.Format("{0,8:0.00000}", reading.Quaternion.Y);
                txtQuaternionZ.Text = String.Format("{0,8:0.00000}", reading.Quaternion.Z);
                txtQuaternionW.Text = String.Format("{0,8:0.00000}", reading.Quaternion.W);

                // Rotation Matrix values
                txtM11.Text = String.Format("{0,8:0.00000}", reading.RotationMatrix.M11);
                txtM12.Text = String.Format("{0,8:0.00000}", reading.RotationMatrix.M12);
                txtM13.Text = String.Format("{0,8:0.00000}", reading.RotationMatrix.M13);
                txtM21.Text = String.Format("{0,8:0.00000}", reading.RotationMatrix.M21);
                txtM22.Text = String.Format("{0,8:0.00000}", reading.RotationMatrix.M22);
                txtM23.Text = String.Format("{0,8:0.00000}", reading.RotationMatrix.M23);
                txtM31.Text = String.Format("{0,8:0.00000}", reading.RotationMatrix.M31);
                txtM32.Text = String.Format("{0,8:0.00000}", reading.RotationMatrix.M32);
                txtM33.Text = String.Format("{0,8:0.00000}", reading.RotationMatrix.M33);
            });
        }
Exemplo n.º 12
0
 void MainPage_ReadingChanged(OrientationSensor sender, OrientationSensorReadingChangedEventArgs args)
 {
 }
Exemplo n.º 13
0
 private void SOrient_ReadingChanged(OrientationSensor sender, OrientationSensorReadingChangedEventArgs args)
 {
     LastOrient = args.Reading;
 }
 async void MainPage_ReadingChanged(OrientationSensor sender, OrientationSensorReadingChangedEventArgs args)
 {
     await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
     });
 }
Exemplo n.º 15
0
 private void OrientationSensorOnReadingChanged(OrientationSensor sender, OrientationSensorReadingChangedEventArgs args)
 {
     _sensorSettings.LatestOrientationSensorReading = args.Reading;
 }
Exemplo n.º 16
0
        private void OnReadingChange(OrientationSensor sender, OrientationSensorReadingChangedEventArgs args)
        {
            SensorQuaternion quaternion = args.Reading.Quaternion;

            Ball.SetAccelaration(quaternion.X, quaternion.Y);
        }
Exemplo n.º 17
0
 private void Or_ReadingChanged(OrientationSensor sender, OrientationSensorReadingChangedEventArgs args)
 {
 }