Esempio n. 1
0
        internal bool UpdateLocation()
        {
            if (Points.Count == 0)
            {
                return(false);
            }
            if (CurrentIndex == Points.Count)
            {
                return(false);
            }

            var    dist     = Math2.GetDistance(Points[CurrentIndex], Timeline.CurrentLocation);
            double dist_max = 50;

            if (CurrentIndex > 0 && CurrentIndex + 1 < Points.Count - 1)
            {
                var nextLine    = Math2.GetPolarHeadingFromLine(Points[CurrentIndex], Points[CurrentIndex + 1]);
                var angle_delta = Math.Abs(Math2.DiffAngles(Math2.GetPolarHeadingFromLine(TargetLine), nextLine));
                dist_max += angle_delta * 2.5;
            }

            if (dist < dist_max)
            {
                CurrentIndex++;
                Trace.WriteLine($"Flight Plan: Advance: {CurrentIndex}");

                App.Current.Dispatcher.BeginInvoke((Action)(() =>
                {
                    PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(CurrentIndex)));
                }));
            }

            return(dist < dist_max);
        }
        private void RenderFrame(TimelineFrame frame)
        {
            Line l = new Line();

            l.Stroke          = Brushes.Yellow;
            l.StrokeThickness = 1;

            if (_lastRenderedFrame != null)
            {
                l.X1 = _lastRenderedFrame.Location.X / Metrics.SCALE_Map4_20_TO_100;
                l.X2 = frame.Location.X / Metrics.SCALE_Map4_20_TO_100;
                l.Y1 = _lastRenderedFrame.Location.Y / Metrics.SCALE_Map4_20_TO_100;
                l.Y2 = frame.Location.Y / Metrics.SCALE_Map4_20_TO_100;

                var len = Math2.GetDistance(_lastRenderedFrame.Location, frame.Location);
                if (len > 5)
                {
                    l.Stroke = Brushes.Red;
                }
            }
            else
            {
                l.X1 = l.X2 = frame.Location.X / Metrics.SCALE_Map4_20_TO_100;
                l.Y1 = l.Y2 = frame.Location.Y / Metrics.SCALE_Map4_20_TO_100;
            }

            canvas.Children.Add(l);
        }
Esempio n. 3
0
        private double OnGlidePathPercent()
        {
            var approach_dist       = Math2.GetDistance(_plan.Points[_plan.CurrentIndex - 1], _plan.Points[_plan.CurrentIndex]);
            var dist_from_threshold = Math2.GetDistance(Timeline.CurrentLocation, _plan.Points[_plan.CurrentIndex]);
            var percent_done        = dist_from_threshold / approach_dist;

            if (percent_done > 1)
            {
                percent_done = 1;
            }
            return(percent_done);
        }