public DerivateForm(MainProgram form)
        {
            this.form = form;
            InitializeComponent();
            GraphProcessing.CreateGraph(firstDerivative, "Первая производная", "X", "Y'", 50, 5);
            GraphProcessing.CreateGraph(secondDerivative, "Вторая производная", "X", "Y''", 50, 5);
            firstDerivative.Tag  = 5;
            secondDerivative.Tag = 5;
            LineItem curve = null;

            form.buttons.Add(GraphProcessing.CreateCurve(ref curve, form.CurvesDropDownButton, firstDerivative, "Первая производная", Color.Red, 6, SymbolType.Circle, Color.Red));
            curve.Tag = 5;
            GraphProcessing.DerivativeGraph(form.getCurve, ref curve);
            LineItem curve2 = null;

            form.buttons.Add(GraphProcessing.CreateCurve(ref curve2, form.CurvesDropDownButton, secondDerivative, "Вторая производная", Color.Blue, 6, SymbolType.Circle, Color.Blue));
            GraphProcessing.SecondDerivativeGraph(curve, ref curve2);
            curve2.Tag = 5;

            LineItem movingAverage = null;

            form.buttons.Add(GraphProcessing.CreateCurve(ref movingAverage, form.CurvesDropDownButton, firstDerivative, "Первая производная 2", Color.Cyan, 6, SymbolType.Circle, Color.Red));
            GraphProcessing.DerivativeGraph(form.processedCurve, ref movingAverage);
            movingAverage.Tag = 5;
            LineItem movingAverageTemp = new LineItem("temp");

            LineItem movingAverage2 = null;

            form.buttons.Add(GraphProcessing.CreateCurve(ref movingAverage2, form.CurvesDropDownButton, secondDerivative, "Вторая производная 2", Color.Cyan, 6, SymbolType.Circle, Color.Red));
            movingAverage2.Tag = 5;
            GraphProcessing.DerivativeGraph(form.processedCurve2, ref movingAverageTemp);
            GraphProcessing.SecondDerivativeGraph(movingAverageTemp, ref movingAverage2);
            GraphProcessing.UpdateGraph(firstDerivative);
            GraphProcessing.UpdateGraph(secondDerivative);
        }
Ejemplo n.º 2
0
        public static void zeroTwoSigma1(LineItem originalCurve, PointPair p2, LineItem LineCurve, LineItem curved2, MainProgram form)
        {
            LineItem curve1 = null;
            LineItem curve2 = null;

            form.buttons.Add(GraphProcessing.CreateCurve(ref curve1, form.CurvesDropDownButton, form.ZGCInstance, "Параллель 1", Color.DarkCyan, 2, SymbolType.Default, Color.DarkCyan));
            curve1 = LineCurve;
            form.buttons.Add(GraphProcessing.CreateCurve(ref curve2, form.CurvesDropDownButton, form.ZGCInstance, "Параллель 2", Color.DarkCyan, 2, SymbolType.Default, Color.DarkCyan));
            //int max = 0;
            //for (int i = 0; i < originalCurve.Points.Count; i++) if (originalCurve.Points[i].X > max) max = (int)originalCurve.Points[i].X;
            //double average = 0;
            //for (int i = 0; i < curved2.Points.Count - 10; i++) average += Math.Abs(curved2[i].Y);
            //average /= curved2.Points.Count - 10;
            //int index = 0;
            //for (index = 0; index < curved2.Points.Count; index++) { if (curved2[index].Y > 10.0 * average) break; }
            double offSetY = originalCurve[originalCurve.Points.Count - 4].Y - p2.Y;
            double offSetX = originalCurve[originalCurve.Points.Count - 4].X - p2.X;

            for (int i = 0; i < LineCurve.Points.Count - 1; i++)
            {
                curve1.AddPoint(new PointPair(LineCurve.Points[i].X + offSetX, LineCurve.Points[i].Y += offSetY));
            }
            int offSetX2 = (int)Math.Round(0.98 * originalCurve.Points[originalCurve.Points.Count - 4].X);

            for (int i = 0; i < curve1.Points.Count; i++)
            {
                curve2.AddPoint(new PointPair(curve1.Points[i].X + offSetX2, curve1.Points[i].Y));
            }
        }
Ejemplo n.º 3
0
        public static PointPair parallelLineSigma(double offSetCoef, MainProgram form, LineItem LineCurve, LineItem originalCurve, double distance, string name)
        {
            double   k1     = form.kCoef;
            double   b1     = (-offSetCoef * distance + form.bCoef);
            LineItem curve3 = new LineItem(name);

            form.buttons.Add(GraphProcessing.CreateCurve(ref curve3, form.CurvesDropDownButton, form.ZGCInstance, name, Color.Purple, 1, SymbolType.Default, Color.Purple));
            for (int i = 0; i < 1.5 * LineCurve[LineCurve.Points.Count - 1].X; i++)
            {
                if ((k1 * i + b1) > 0)
                {
                    curve3.AddPoint(new PointPair(i, k1 * i + b1));
                }
            }
            curve3.Tag = 1;
            bool      intersects = false;
            int       index1     = 1;
            PointPair temp       = null;

            while (index1 < originalCurve.Points.Count - 2 && !intersects)
            {
                PointPair point1 = originalCurve[index1 - 1];
                PointPair point2 = originalCurve[index1];
                temp = lineLineIntersection(point1, point2, k1, b1);
                if (temp.X >= point1.X && temp.X <= point2.X)
                {
                    if (temp.Y >= point1.Y && temp.Y <= point2.Y)
                    {
                        intersects = true;
                    }
                }
                index1++;
            }
            return(temp);
        }
Ejemplo n.º 4
0
        public static double[] LeastSquareData(LineItem allPointsForBuilding)
        {
            double[] xData = GraphProcessing.CurveToArray(allPointsForBuilding, true);
            double[] yData = GraphProcessing.CurveToArray(allPointsForBuilding, false);
            var      ds    = new XYDataSet(xData, yData);
            double   k     = ds.Slope;
            double   b     = ds.YIntercept;

            return(new double[] { k, b });
        }
Ejemplo n.º 5
0
 public void clear()
 {
     GraphProcessing.RemoveLine(PARALELL1_NAME, form);
     GraphProcessing.RemoveLine(PARALELL2_NAME, form);
     if (zeroTwoCB.Checked)
     {
         GraphProcessing.RemoveLine(SIGMANZEROTWO, form);
     }
     else
     {
         GraphProcessing.RemoveLine(SIGMANZEROFIVE, form);
     }
 }
Ejemplo n.º 6
0
        private void OnClosing(object sender, CancelEventArgs cancelEventArgs)
        {
            switch (MessageBox.Show("Вы точно хотите выйти?", "Внимание", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
            {
            case DialogResult.Yes:
                GraphProcessing.OnClosingMethod(form);
                break;

            case DialogResult.No:
                cancelEventArgs.Cancel = true;
                break;
            }
        }
        //kostil
        public void removeBigValue()
        {
            var curve = form.getCurve;

            for (int i = 0; i < curve.Points.Count; i++)
            {
                if (curve.Points[i].Y > 6 * Math.Pow(10, 6))
                {
                    curve.RemovePoint(i);
                }
            }
            GraphProcessing.UpdateGraph(form.ZGCInstance);
        }
Ejemplo n.º 8
0
        public static void zeroTwoSigma2(LineItem originalCurve, PointPair p2, LineItem LineCurve, LineItem curved2, MainProgram form)
        {
            LineItem curve1 = null;
            LineItem curve2 = null;

            form.buttons.Add(GraphProcessing.CreateCurve(ref curve1, form.CurvesDropDownButton, form.ZGCInstance, "Паралелль 1", Color.DarkCyan, 4, SymbolType.Default, Color.DarkCyan));
            form.buttons.Add(GraphProcessing.CreateCurve(ref curve2, form.CurvesDropDownButton, form.ZGCInstance, "Паралелль 2", Color.DarkCyan, 4, SymbolType.Default, Color.DarkCyan));

            int max = 0;

            for (int i = 0; i < originalCurve.Points.Count; i++)
            {
                if (originalCurve.Points[i].X > max)
                {
                    max = (int)originalCurve.Points[i].X;
                }
            }
            double average = 0;

            for (int i = 0; i < curved2.Points.Count - 10; i++)
            {
                average += Math.Abs(curved2[i].Y);
            }
            average /= curved2.Points.Count - 10;
            int index = 0;

            for (index = 0; index < curved2.Points.Count; index++)
            {
                if (curved2[index].Y > 10.0 * average)
                {
                    break;
                }
            }
            double offSetY = originalCurve[index].Y - p2.Y;
            double offSetX = originalCurve[index].X - p2.X;

            for (int i = 0; i < LineCurve.Points.Count - 1; i++)
            {
                double x = LineCurve.Points[i].X - offSetX;
                double y = LineCurve.Points[i].Y + offSetY;
                curve1.AddPoint(new PointPair(x, y));
            }
            int offSetX2 = (int)Math.Round(0.8 * curve1.Points[0].X);

            for (int i = 0; i < curve1.Points.Count; i++)
            {
                curve2.AddPoint(new PointPair(curve1.Points[i].X - offSetX2, curve1.Points[i].Y));
            }
            curve1.Tag = 5;
            curve2.Tag = 5;
        }
Ejemplo n.º 9
0
 private void DynamicButton_Click(object sender, EventArgs e)
 {
     if (!button.Checked)
     {
         zgc.GraphPane.CurveList.Add(curve);
         zgc.GraphPane.CurveList.Draw(zgc.CreateGraphics(), zgc.GraphPane, 1.0f);
     }
     else
     {
         zgc.GraphPane.CurveList.Remove(curve);
     }
     GraphProcessing.UpdateGraph(zgc);
     button.Checked = !button.Checked;
 }
 private void decline_Click(object sender, EventArgs e)
 {
     if (!isUsed)
     {
         MessageBox.Show("Вы не построили линию", "Внимание");
     }
     else
     {
         GraphProcessing.RemoveSelection(form);
         closeForm();
         GraphProcessing.RemoveSelection(form);
         form.readingStressFlowForm = new ChooseStressFlow(form);
         form.readingStressFlowForm.Show();
         form.readingStressFlowForm.Focus();
         form.readingStressFlowForm.BringToFront();
     }
 }
 private void CustomLine_Load(object sender, EventArgs e)
 {
     GraphProcessing.calculateSize(form.ZGCInstance);
     //if (form.ZGCInstance.GraphPane.YAxis.Scale.Max > 6 * Math.Pow(10, 6))
     //{
     //    form.ZGCInstance.GraphPane.YAxis.Scale.MinAuto = true;
     //    form.ZGCInstance.GraphPane.YAxis.Scale.MaxAuto = true;
     //    form.ZGCInstance.GraphPane.YAxis.Scale.MajorStepAuto = true;
     //    form.ZGCInstance.GraphPane.YAxis.Scale.MinorStepAuto = true;
     //    form.ZGCInstance.GraphPane.YAxis.CrossAuto = true;
     //    form.ZGCInstance.GraphPane.YAxis.Scale.MagAuto = true;
     //    form.ZGCInstance.GraphPane.YAxis.Scale.FormatAuto = true;
     //}
     form.unsubscribe();
     removeBigValue();
     base.Closing += OnClosing;
 }
        private void firstDerivative_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            double stepX = 10;//Math.Log10(Math.Abs(firstDerivative.ScrollMaxX - firstDerivative.ScrollMinX));
            double stepY = 1; Math.Log10(Math.Abs(firstDerivative.ScrollMaxY - firstDerivative.ScrollMinY));

            if (e.KeyCode == Keys.Up)
            {
                firstDerivative.ScrollMinY  += stepY;
                firstDerivative.ScrollMaxY  += stepY;
                secondDerivative.ScrollMinY += stepY;
                secondDerivative.ScrollMaxY += stepY;
            }


            if (e.KeyCode == Keys.Down)
            {
                firstDerivative.ScrollMinY  -= stepY;
                firstDerivative.ScrollMaxY  -= stepY;
                secondDerivative.ScrollMinY -= stepY;
                secondDerivative.ScrollMaxY -= stepY;;
            }

            if (e.KeyCode == Keys.Left)
            {
                firstDerivative.ScrollMinX  -= stepX;
                firstDerivative.ScrollMaxX  -= stepX;
                secondDerivative.ScrollMinX -= stepX;
                secondDerivative.ScrollMaxX -= stepX;
            }

            if (e.KeyCode == Keys.Right)
            {
                firstDerivative.ScrollMinX  += stepX;
                firstDerivative.ScrollMaxX  += stepX;
                secondDerivative.ScrollMinX += stepX;
                secondDerivative.ScrollMaxX += stepX;
            }
            GraphProcessing.UpdateGraph(firstDerivative);
            GraphProcessing.UpdateGraph(secondDerivative);
        }
        private void accept_Click(object sender, EventArgs e)
        {
            aproximateLinearCurve = null;
            GraphProcessing.RemoveLine(MNK_NAME, form);
            GraphProcessing.RemoveLine(MNK_NAME, form);
            GraphProcessing.RemoveLine(REG_NAME, form);

            GraphProcessing.UpdateGraph(form.ZGCInstance);
            if (form.SelectionCurveBegin != null && form.SelectionCurveEnd != null)
            {
                int index = form.ZGCInstance.GraphPane.CurveList.IndexOf(MNK_NAME);
                if (index >= 0)
                {
                    form.ZGCInstance.GraphPane.CurveList.RemoveAt(index);
                    DynamicToolStripButton tempBtn = null;
                    for (int i = 0; i < form.buttons.Count; i++)
                    {
                        string test = form.buttons[i].curve.Label.Text;
                        if (test == MNK_NAME)
                        {
                            tempBtn = form.buttons[i]; break;
                        }
                    }
                    form.CurvesDropDownButton.DropDownItems.Remove(tempBtn.button); //ошибка
                }


                PointPairList tempPointPair = (PointPairList)form.getCurve.Points;
                double        beginX        = tempPointPair.IndexOf(form.SelectionCurveBegin.Points[0]);
                double        endX          = tempPointPair.IndexOf(form.SelectionCurveEnd.Points[0]);
                int           begin         = (int)Math.Min(beginX, endX);
                int           end           = (int)Math.Max(beginX, endX);
                LineItem      temp          = new LineItem("tempCurve");
                temp.Tag = 5;

                if (form.getCurve != null)
                {
                    if (leastSquaresMode)
                    {
                        for (int i = begin; i < end; i++)
                        {
                            temp.AddPoint(form.getCurve.Points[i]);
                        }
                        begin = (int)form.getCurve.Points[begin].X;
                        end   = (int)form.getCurve.Points[end].X;

                        form.buttons.Add(GraphProcessing.CreateCurve(ref aproximateLinearCurve, form.CurvesDropDownButton, form.ZGCInstance, MNK_NAME, Color.Green, 2, SymbolType.Default, Color.Green));
                        aproximateLinearCurve.Tag = 2;
                        double[] data = MyMath.leastSquaresBuild(begin, end, temp, ref aproximateLinearCurve, form);
                        form.kCoef = data[0];
                        form.bCoef = data[1];
                        form.ZGCInstance.Refresh();
                        GraphProcessing.UpdateGraph(form.ZGCInstance);

                        form.AproximateLinearCurve = aproximateLinearCurve;
                    }
                    if (regularMode)
                    {
                        aproximateLinearCurve = null;
                        double x1 = form.getCurve.Points[begin].X;
                        double y1 = form.getCurve.Points[begin].Y;

                        double x2 = form.getCurve.Points[end].X;
                        double y2 = form.getCurve.Points[end].Y;

                        // y= y1+(x-x1) (y2 - y1) / (x2-x1) ; y = k*(x-x1) + y1 = kx - (kx1 + y1)

                        double coef = (y2 - y1) / (x2 - x1);

                        form.buttons.Add(GraphProcessing.CreateCurve(ref aproximateLinearCurve, form.CurvesDropDownButton, form.ZGCInstance, REG_NAME, Color.DarkCyan, 6, SymbolType.Circle, Color.DarkCyan));
                        for (int i = (int)form.getCurve.Points[(int)begin].X; i < form.getCurve.Points[(int)end].X; i++)
                        {
                            aproximateLinearCurve.AddPoint(new PointPair(i, coef * (i - x1) + y1));
                        }
                        form.AproximateLinearCurve = aproximateLinearCurve;
                        GraphProcessing.UpdateGraph(form.ZGCInstance);
                        LineItem curveTemp = form.getCurve;
                        curveTemp.Tag             = 5;
                        aproximateLinearCurve.Tag = 2;
                        //MyMath.buildLine(form.secondDerivativeCurve, ref curveTemp, form);
                        form.getCurve = curveTemp;

                        GraphProcessing.UpdateGraph(form.ZGCInstance);
                        //y = (x-x1)*(y2-y1)/(x2-x1) + y1
                    }
                    isUsed = true;
                }

                //if (form.processedCurve != null) { form.ZGCInstance.GraphPane.CurveList.Remove(form.processedCurve); form.processedCurve = null; }
                //if (form.processedCurve2 != null) {  form.ZGCInstance.GraphPane.CurveList.Remove(form.processedCurve2); form.processedCurve2 = null; }
            }
            else
            {
                MessageBox.Show("Выберите две точки на прямой который будут использованы для построения прямой");
            }
            info.Text = form.getCurve.Points.Count.ToString();
        }
Ejemplo n.º 14
0
        private void button1_Click(object sender, EventArgs e)
        {
            bool   error = false;
            double aDimnesion = 0, bDimension = 0, originalLength = 0, endLength = 0, maxForce = 0;

            if (endLengthTB.ReadOnly)
            {
                if (double.TryParse(aDimTB.Text, out aDimnesion) && (double.TryParse(bDimTB.Text, out bDimension) | bDimTB.ReadOnly) && double.TryParse(startLength.Text, out originalLength))
                {
                    if (!form.Port.IsOpen)
                    {
                        try
                        {
                            form.Port.Open();
                        }
                        catch (System.UnauthorizedAccessException ex) { MessageBox.Show(ex.Message); error = true; }
                    }
                    if (!error)
                    {
                        form.aDim           = aDimnesion;
                        form.bDim           = bDimension;
                        form.originalLength = originalLength;
                        form.metalMarking   = markingTB.Text;
                        form.type           = typeCB.Text;

                        form.ZGCInstance.GraphPane.Title.Text = markingTB.Text;
                        this.Visible = false;

                        GraphProcessing.resetGraph(form);
                        form.subscribe();
                    }
                }
                else
                {
                    MessageBox.Show("Неверно введены параметры.");
                }
            }
            else
            {
                if (double.TryParse(endLengthTB.Text, out endLength) && double.TryParse(bDimTB.Text, out bDimension))
                {
                    if (form.ViewIsPressed)
                    {
                        form.readingInOneSession.RemoveAt(form.readingInOneSession.Count - 1);
                    }
                    double max = Double.MinValue;
                    for (int i = 0; i < form.getCurve.Points.Count; i++)
                    {
                        if (form.getCurve.Points[i].Y > max)
                        {
                            max = form.getCurve.Points[i].Y;
                        }
                    }
                    maxForce = max;



                    form.endLength      = Math.Round(endLength, 2);
                    form.originalLength = Math.Round(form.originalLength, 2);
                    form.maxForce       = (int)maxForce;

                    form.relativeExpansion  = 1;
                    form.tempTearResistance = 1;


                    form.stressFlow        = new int?[2];
                    form.forceAtStressFlow = new int?[2];
                    for (int i = 0; i < form.yieldPoints.Length; i++)
                    {
                        if (form.yieldPoints[i] != null)
                        {
                            form.forceAtStressFlow[i] = (int?)Math.Round((form.yieldPoints[i].Y));
                        }
                    }
                    form.relativeExpansion = Math.Abs(Math.Round((((form.endLength / form.originalLength) - 1) * 100), 1));
                    if (form.type == "Плоская")
                    {
                        form.aDim      = Math.Round(form.aDim, 2);
                        form.bDim      = Math.Round(form.bDim, 2);
                        form.totalArea = Math.Round(form.aDim * form.bDim, 2);
                        for (int i = 0; i < form.forceAtStressFlow.Length; i++)
                        {
                            if (form.forceAtStressFlow[i] != null)
                            {
                                form.stressFlow[i] = (int?)(form.forceAtStressFlow[i] / form.totalArea);
                            }
                        }
                        form.tempTearResistance = Math.Round(maxForce / form.totalArea);
                        form.readingInOneSession.Add(new Classes.ExperimentReading(form.metalMarking, form.aDim, form.bDim, form.totalArea, form.originalLength, form.endLength, form.maxForce, form.forceAtStressFlow, form.stressFlow, form.tempTearResistance, form.relativeExpansion, form.yieldPoints));
                    }
                    if (form.type == "Цилиндрическая")
                    {
                        form.bDim           = bDimension;
                        form.diameterAfter  = Math.Round(bDimension, 2);
                        form.diameterBefore = Math.Round(form.aDim, 2);
                        form.totalArea      = Math.Round(((Math.PI * form.diameterBefore * form.diameterBefore) / 4), 2);
                        for (int i = 0; i < form.forceAtStressFlow.Length; i++)
                        {
                            if (form.forceAtStressFlow[i] != null)
                            {
                                form.stressFlow[i] = (int?)(form.forceAtStressFlow[i] / form.totalArea);
                            }
                        }
                        form.tempTearResistance = Math.Round(maxForce / form.totalArea);

                        form.relativeNarrowing = 100 * Math.Abs(Math.Round(((((Math.PI * form.diameterAfter * form.diameterAfter) / 4) / form.totalArea)), 1));
                        form.readingInOneSession.Add(new Classes.ExperimentReading(form.metalMarking, form.aDim, form.bDim, form.totalArea, form.originalLength, form.endLength, form.maxForce, form.forceAtStressFlow, form.stressFlow, form.tempTearResistance, form.relativeExpansion, form.relativeNarrowing, form.yieldPoints));
                    }

                    int pos = form.ZGCInstance.GraphPane.CurveList.IndexOf("Точка 1");
                    if (pos > 0)
                    {
                        form.ZGCInstance.GraphPane.CurveList.RemoveAt(pos);
                    }

                    int pos2 = form.ZGCInstance.GraphPane.CurveList.IndexOf("Точка 2");
                    if (pos2 > 0)
                    {
                        form.ZGCInstance.GraphPane.CurveList.RemoveAt(pos2);
                    }



                    double coefOfDiv        = Math.Abs((form.originalLength - form.endLength) / (form.IntersectionPointEnd - form.IntersectionPointBegin));
                    double distance         = form.IntersectionPointEnd;
                    double distancePositive = form.originalLength;
                    foreach (LineItem elem in form.ZGCInstance.GraphPane.CurveList)
                    {
                        for (int i = 0; i < elem.Points.Count; i++)
                        {
                            elem[i].X -= distance;
                            elem[i].X *= coefOfDiv;
                            elem[i].X += distancePositive;
                            form.ZGCInstance.GraphPane.XAxis.Title.Text = "L, мм";
                        }
                    }
                    GraphProcessing.UpdateGraph(form.ZGCInstance);

                    //form.MinXValue = form.originalLength;
                    //form.MaxXValue = form.endLength;
                    //form.MinYValue = 0;
                    //int maxYValueLocal = Int32.MinValue;
                    //for (int i = 0; i < form.getCurve.Points.Count; i++) if (form.getCurve[i].Y > maxYValueLocal) maxYValueLocal =  (int) form.getCurve[i].Y;
                    //form.MaxYValue = 1.2* maxYValueLocal;

                    //form.ZGCInstance.GraphPane.YAxis.MajorGrid.DashOff = (float) form.MaxYValue/10;
                    //form.ZGCInstance.GraphPane.XAxis.MajorGrid.DashOff = (float)form.MaxXValue /10;
                    form.ZGCInstance.RestoreScale(form.ZGCInstance.GraphPane);
                    GraphProcessing.UpdateGraph(form.ZGCInstance);


                    try
                    {
                        Bitmap   imageOfGraph = form.ZGCInstance.GraphPane.GetImage();
                        Graphics g            = Graphics.FromImage(imageOfGraph);
                        Bitmap   temp         = imageOfGraph;
                        temp.Save(Parsing.CheckForDuplicateImage(form.savePath, form.savePath, form.GraphName), System.Drawing.Imaging.ImageFormat.Bmp);
                    }
                    catch (Exception ex) { MessageBox.Show(ex.ToString()); }

                    ShowDialogueBox(form);
                }
            }
        }
Ejemplo n.º 15
0
        public static PointPair Sigma(LineItem originalCurve, PointPair p2, LineItem LineCurve, LineItem curved2, MainProgram form, bool zeroTwo, string name)
        {
            int index = originalCurve.Points.Count - 4;

            double[] xData   = GraphProcessing.CurveToArray(LineCurve, true);
            double[] yData   = GraphProcessing.CurveToArray(LineCurve, false);
            double   offSetY = originalCurve[index].Y - p2.Y;
            double   offSetX = originalCurve[index].X - p2.X;

            for (int i = 0; i < xData.Length; i++)
            {
                xData[i] += offSetX;
                yData[i] += offSetY;
            }

            var      ds    = new XYDataSet(xData, yData);
            double   k     = ds.Slope;
            double   b     = ds.YIntercept;
            LineItem curve = null;

            form.buttons.Add(GraphProcessing.CreateCurve(ref curve, form.CurvesDropDownButton, form.ZGCInstance, "Параллель 1", Color.DarkCyan, 1, SymbolType.Default, Color.DarkCyan));

            int curveLength = originalCurve.Points.Count;

            for (int i = 0; i < 1.1 * originalCurve.Points[curveLength - 5].X; i++)
            {
                if ((k * i + b) > 0)
                {
                    curve.AddPoint(new PointPair(i, k * i + b));
                }
            }
            // y = kx + b x = (y-b)/k; kx = b = > x = k/b
            double pos = Math.Abs(b / k);

            curve.AddPoint(new PointPair(pos, 0));

            int offSetX2 = (int)Math.Round(0.8 * curve.Points[0].X);

            LineItem curve2;

            curve2 = LineCurve.Clone();
            form.buttons.Add(GraphProcessing.CreateCurve(ref curve2, form.CurvesDropDownButton, form.ZGCInstance, "Параллель 2", Color.DarkCyan, 1, SymbolType.Default, Color.DarkCyan));
            for (int i = 0; i < LineCurve[0].X; i++)
            {
                if ((form.kCoef * i + form.bCoef) > 0)
                {
                    curve2.AddPoint(new PointPair(i, form.kCoef * i + form.bCoef));
                }
            }
            curve2.AddPoint(new PointPair(Math.Abs(form.bCoef / form.kCoef), 0));
            form.IntersectionPointBegin = curve[curve.Points.Count - 1].X;
            form.IntersectionPointEnd   = curve2[curve2.Points.Count - 1].X;
            curve.Tag  = 5;
            curve2.Tag = 1;

            // y = kx + b
            // y = k(x+0.02) + b
            // y = kx + 0.02k + b
            // yy = kx + (0.02k + b

            // -kx + y = b
            double    distance = Math.Abs(form.IntersectionPointEnd - form.IntersectionPointBegin);
            PointPair temp     = new PointPair(0, 0);

            if (zeroTwo)
            {
                temp = parallelLineSigma(0.02, form, LineCurve, originalCurve, distance, name);
            }
            else
            {
                temp = parallelLineSigma(0.05, form, LineCurve, originalCurve, distance, name);
            }

            GraphProcessing.UpdateGraph(form.ZGCInstance);
            return(temp);
        }