Example #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Solve();

            if (_lineFitter.Errored)
            {
                return;
            }

            double xMin = double.MaxValue;
            double xMax = double.MinValue;

            foreach (Vector2 p in TestPoints)
            {
                if (xMin > p.X)
                {
                    xMin = p.X;
                }
                if (xMax < p.X)
                {
                    xMax = p.X;
                }
            }


            CS2dLine line = new CS2dLine()
            {
                StartPoint = new Point(xMin, Line.GetY(xMin)),
                EndPoint   = new Point(xMax, Line.GetY(xMax)),
                Stroke     = new SolidColorBrush(Colors.Black),
                Thickness  = 1
            };

            line.Value = _lineFitter.Line;

            CS2dElements.Add(line);
            _canvas.Elements = CS2dElements;
        }
Example #2
0
        private void SetResult()
        {
            if (_fitter.Errored)
            {
                return;
            }

            double xMin = double.MaxValue;
            double xMax = double.MinValue;

            foreach (Vector2 p in TestPoints)
            {
                if (xMin > p.X)
                {
                    xMin = p.X;
                }
                if (xMax < p.X)
                {
                    xMax = p.X;
                }
            }


            CS2dLine line = new CS2dLine()
            {
                StartPoint = new Point(xMin, Line.GetY(xMin)),
                EndPoint   = new Point(xMax, Line.GetY(xMax)),
                Stroke     = new SolidColorBrush(Colors.Black),
                Thickness  = 1
            };

            line.Value = _fitter.Line;

            _cs2dElements.Add(line);
            _cs2d.Elements = _cs2dElements;
        }