コード例 #1
0
 public static double PlotAreaToWorldAreaX(double x, PlotArea plotArea, WorldArea worldArea)
 {
     return(worldArea.XMin + (((x - plotArea.XMin) * (worldArea.XMax - worldArea.XMin)) / (plotArea.XMax - plotArea.XMin)));;
 }
コード例 #2
0
 public static double PlotAreaToWorldAreaY(double y, PlotArea plotArea, WorldArea worldArea)
 {
     return(worldArea.YMin - (((y - plotArea.YMax) * (worldArea.YMax - worldArea.YMin)) / (plotArea.YMax - plotArea.YMin)));
 }
コード例 #3
0
 public static Point PlotAreaToWorldArea(Point point, PlotArea plotArea, WorldArea worldArea)
 {
     return(PlotAreaToWorldArea(point.X, point.Y, plotArea, worldArea));
 }
コード例 #4
0
 public static double WorldAreaToPlotAreaY(double y, PlotArea plotArea, WorldArea worldArea)
 {
     return(plotArea.YMax - (((y - worldArea.YMin) * (plotArea.YMax - plotArea.YMin)) / (worldArea.YMax - worldArea.YMin)));
 }
コード例 #5
0
        public static Point WorldAreaToPlotArea(double x, double y, PlotArea plotArea, WorldArea worldArea)
        {
            double px, py;

            px = plotArea.XMin + (((x - worldArea.XMin) * (plotArea.XMax - plotArea.XMin)) / (worldArea.XMax - worldArea.XMin));
            py = plotArea.YMax - (((y - worldArea.YMin) * (plotArea.YMax - plotArea.YMin)) / (worldArea.YMax - worldArea.YMin));
            return(new Point(px, py));
        }
コード例 #6
0
        public static Point PlotAreaToWorldArea(double x, double y, PlotArea plotArea, WorldArea worldArea)
        {
            double wx, wy;

            wx = worldArea.XMin + (((x - plotArea.XMin) * (worldArea.XMax - worldArea.XMin)) / (plotArea.XMax - plotArea.XMin));
            wy = worldArea.YMin - (((y - plotArea.YMax) * (worldArea.YMax - worldArea.YMin)) / (plotArea.YMax - plotArea.YMin));
            return(new Point(wx, wy));
        }
コード例 #7
0
        // private object _selectedSpline;
        //private FunctionComboBoxViewModel functionComboBoxViewModel;
        /**********************/

        public MainPage()
        {
            InitializeComponent();
            this.DrawPrecision      = DEFAULT_DRAW_PRECISION;
            this.RedrawingPrecision = DEFAULT_REDRAWING_PRECISION;
            //functionComboBoxViewModel = new FunctionComboBoxViewModel();
            _plotArea  = new PlotArea(PLOT_AREA_MIN_X, PLOT_AREA_MAX_X, PLOT_AREA_MIN_Y, PLOT_AREA_MAX_Y);
            _worldArea = new WorldArea(WORLD_AREA_DEFAULT_MIN_XY, WORLD_AREA_DEFAULT_MAX_XY, WORLD_AREA_DEFAULT_MIN_XY, WORLD_AREA_DEFAULT_MAX_XY);
            // _pa.x_min = 0; _pa.x_max = 775; _pa.y_min = 0; _pa.y_max = 575; _wa.x_min = -10; _wa.x_max = 10; _wa.y_min = -10; _wa.y_max = 10;
            _engine = new SplineDrawer(canvas1, _plotArea, _worldArea, DrawPrecision);
            //_auxiliaryEngine = new AuxiliaryDrawer(canvas1);
            _isMoving = false;
            _waZeroPointInPACoordinates = TransformCoordinates.WorldAreaToPlotArea(0, 0, _plotArea, _worldArea);

            _parser = new Parser();
            InitSplineLists();
            _canvasUtilities = new CanvasUtilities(_plotArea, _worldArea);

            _openFileDialog = new OpenFileDialog();
            _saveFileDialog = new SaveFileDialog();
            InitColors();
            FunctionSelect_ComboBox.SelectedIndex = 0;
            _dragInfoLabel = new DragInfoLabel(CANVAS_TEXT_COLOR);
            //_dragInfoLabel.Margin = new Thickness(20, 30, 0, 0);
            //_dragInfoLabel.Content = "SDAS";
            canvas1.Children.Add(_dragInfoLabel);
            _dragInfoLabel.Visibility = Visibility.Collapsed;
            VersionLabel.Content      = Version();

            try
            {
                this._saveFileDialog.DefaultExt  = ".spline";
                this._openFileDialog.Filter      = "Spline Files|*.spline";
                this._openFileDialog.FilterIndex = 2;
                this._saveFileDialog.Filter      = "Spline Files|*.spline";
                this._saveFileDialog.FilterIndex = 2;
                // this._saveFileDialog.DefaultFileName = "newSplines.spline";
            }
            catch (Exception)
            {
            }
            DefaultCanvas();
            //var s = BSpline.ServiceKnots(new double[] {2,3.75,5},3,true);

            // _engine.BellFunctionOfDegree3(0, 1, 2, 3, 4);
            // _engine.BSplineBasisFunctionsOfDegree3(0, 1, 2, 3, 4, 5, 6, 7);
            //_engine.BSplineBasisFunction(new double[]{0, 1, 2, 3, 4, 5, 6, 7});
            // double[] knots = new double[] {-1,1,2,2.5, 3, 4, 5, 6};
            // Tuple<double[][], double[]> A = GlobalBSplineMatrix(3, knots);
            // double[][] B = A.Item1; //MathMyUtils.MatrixInvert(A.Item1);
            // //double[][] F = MathMyUtils.MatrixInvert(B);
            //// double[][] C = MathMyUtils.TransposeMatrix(B);

            //// //double[][] D = MathMyUtils.MatrixInvert(MathMyUtils.MultiplyMatrices(C, B));
            //// //double[][] E = MathMyUtils.MultiplyMatrices(B, C);
            ////// double[][] YMatrix = MathMyUtils.ArrayToMatrix(knotsFunctionValues);
            // for (int i = 0; i < B.Length; i++)
            // {
            //     String s = "";
            //     for (int j = 0; j < B[i].Length; j++)
            //     {

            //         s += B[i][j].ToString() + " | ";
            //     }
            //     System.Diagnostics.Debug.WriteLine(s);
            // }
        }
コード例 #8
0
        public new Tuple <double, double, double, double> Range_MinX_MaxX_MinY_MaxY(PlotArea plotArea, WorldArea worldArea)
        {
            double minX = double.MaxValue;
            double maxX = double.MinValue;
            double minY = double.MaxValue;
            double maxY = double.MinValue;

            for (int i = 0; i < LinesOfSpline.Count; i++)
            {
                var X1 = TransformCoordinates.PlotAreaToWorldAreaX(LinesOfSpline[i].X1, plotArea, worldArea);
                var X2 = TransformCoordinates.PlotAreaToWorldAreaX(LinesOfSpline[i].X2, plotArea, worldArea);
                var Y1 = TransformCoordinates.PlotAreaToWorldAreaY(LinesOfSpline[i].Y1, plotArea, worldArea);
                var Y2 = TransformCoordinates.PlotAreaToWorldAreaY(LinesOfSpline[i].Y2, plotArea, worldArea);
                if (X1 < minX)
                {
                    minX = X1;
                }
                if (X2 > maxX)
                {
                    maxX = X2;
                }
                if (Y1 < minY)
                {
                    minY = Y1;
                }
                if (Y2 > maxY)
                {
                    maxY = Y2;
                }
            }

            //for (int i = 0; i < DragEllipses.Count; i++)
            //{
            //    var X = TransformCoordinates.PlotAreaToWorldAreaX(DragEllipses[i]., plotArea, worldArea);
            //    var Y = TransformCoordinates.PlotAreaToWorldAreaY(DragEllipses[i].X2, plotArea, worldArea);
            //}

            return(Tuple.Create(minX, maxX, minY, maxY));
        }
コード例 #9
0
 public CanvasUtilities(PlotArea plotArea, WorldArea worldArea)
 {
     this._plotArea  = plotArea;
     this._worldArea = worldArea;
 }
コード例 #10
0
 public SplineDrawer(Canvas canvas, PlotArea pa, WorldArea wa, double drawPrecision, AuxiliaryDrawer auxiliaryEngine)
 {
     Initialize(canvas, pa, wa, drawPrecision);
     _auxiliaryEngine = auxiliaryEngine;
 }
コード例 #11
0
 public SplineDrawer(Canvas canvas, PlotArea pa, WorldArea wa, double drawPrecision)
 {
     Initialize(canvas, pa, wa, drawPrecision);
     //DrawPrecisionDiv2 = DrawPrecisionDiv2 / 2;
     _auxiliaryEngine = new AuxiliaryDrawer(canvas);
 }