private void buttonGetAxisCollisionPoints_Click(object sender, EventArgs e) { Equation eq = equations[listBoxEquations.SelectedIndex]; float prevX = eq.FromX; if (eq is Sqrt_Equation && prevX < 0) { prevX = 0f; } float step = (float)numericUpDownAxisCollisionPointsAccuracy.Value; if (numericUpDownAxisCollisionPointsAccuracy.Value == 0) { step = 1; } float prevY = eq.GetValueInPoint(prevX); while (prevX <= eq.ToX) { float curX = prevX + 1 / step; float curY = eq.GetValueInPoint(curX); if (float.IsNaN(curY)) { prevX += 1 / step; continue; } if ((int)(curX * 100) == 0 && !float.IsNaN(curY)) { AxisCollisionPoints.Add(new Point((int)(curX * 100), (int)(curY * 100))); } if ((int)(curY * 100) == 0) { AxisCollisionPoints.Add(new Point((int)(curX * 100), (int)(curY * 100))); } prevX = curX; prevY = curY; } pictureBoxMainField.Refresh(); if (AxisCollisionPoints.Count > 0) { MessageBox.Show("Точки пересечения графика с осями координат\n" + String.Join("\n", AxisCollisionPoints.Select(t => t.X.ToString("0.00") + "; " + t.Y.ToString("0.00")))); } else { MessageBox.Show("Точки пересечения графика с осями координат не найдены"); } }
private void buttonIsUpperOrLower_Click(object sender, EventArgs e) { Equation eq = equations[listBoxEquations.SelectedIndex]; float pointX = float.Parse(textBoxPointX.Text.Replace('.', ',')); float pointY = float.Parse(textBoxPointY.Text.Replace('.', ',')); if (eq.GetValueInPoint(pointX) > pointY) { MessageBox.Show("Точка ниже графика"); } else if (eq.GetValueInPoint(pointX) < pointY) { MessageBox.Show("Точка выше графика"); } else if (eq.GetValueInPoint(pointX) == pointY) { MessageBox.Show("Точка принадлежит графику"); } }
private void buttonFindMinAndMax_Click(object sender, EventArgs e) { float Lowest = float.MaxValue; float Highest = float.MinValue; Equation eq = equations[listBoxEquations.SelectedIndex]; float prevX = eq.FromX; float step = 100f; float prevY = eq.GetValueInPoint(prevX); while (prevX <= eq.ToX) { float curX = prevX + 1 / step; float curY = eq.GetValueInPoint(curX); if (float.IsNaN(curY)) { prevX += 1 / step; continue; } if (curY < Lowest) { Lowest = curY; MinFuncPoint = new PointF(curX, Lowest); } if (curY > Highest) { Highest = curY; MaxFuncPoint = new PointF(curX, Highest); } prevX = curX; prevY = curY; } pictureBoxMainField.Refresh(); MessageBox.Show("Минимальное значение на заданном промежутке\n" + Lowest.ToString("0.00") + "\nМаксимальное значение на заданном промежутке\n" + Highest.ToString("0.00")); }
private void buttonFuncValueInPoint_Click(object sender, EventArgs e) { Equation eq = equations[listBoxEquations.SelectedIndex]; float pointX = float.Parse(textBoxPointX.Text.Replace('.', ',')); if (eq.FromX > pointX || eq.ToX < pointX) { MessageBox.Show("Выбранная координата не принадлежит области определения"); return; } float valueInPoint = eq.GetValueInPoint(pointX); if (!float.IsNaN(valueInPoint)) { SelectedPointOfEquation = new PointF(pointX, valueInPoint); pictureBoxMainField.Refresh(); MessageBox.Show("Значение функции в точке " + pointX.ToString("0;00") + " = " + valueInPoint.ToString("0")); } else { MessageBox.Show("Значение функции в точке " + pointX.ToString("0;00") + " " + "не существует"); } }
public PointF GetCurrentDisplayPoint() { return(new PointF(currentX, way.GetValueInPoint(currentX))); }