private void ButtonDivide_Click(object sender, RoutedEventArgs e) { plotView.Model.Series.Clear(); FuzzyNumber result = new FuzzyNumber(); int scale; ParseFNTextBoxes(); TryParse(textBoxDiscretization.Text, out var disPara); FuzzyNumber fuzzyNumberA = new FuzzyNumber(a1, a2, a3, a4, disPara); FuzzyNumber fuzzyNumberB = new FuzzyNumber(b1, b2, b3, b4, disPara); result = FNAlgebra.divideAB(fuzzyNumberA, fuzzyNumberB); if (fuzzyNumberA.detectFailureChange(result)) { textBoxOutput.Text = "You can't divide by 0"; } else { resultToContinue = result; textBoxOutput.Text = "{ " + result + "}"; scale = result.findMaxValueOfFuzzyNumber(fuzzyNumberA, fuzzyNumberB, result); PlotModelDefine.ScalePlotOFN(plotView.Model, scale); plotView.Model.Series.Add(PlotModelDefine.drawFuzzyNumber(fuzzyNumberA, disPara, "Number A")); plotView.Model.Series.Add(PlotModelDefine.drawFuzzyNumber(fuzzyNumberB, disPara, "Number B")); plotView.Model.Series.Add(PlotModelDefine.drawFuzzyNumber(result, disPara, "Result")); plotView.Model.Series.Add(PlotModelDefine.drawFuzzyNumberOrder(fuzzyNumberA, disPara, "Number A")); plotView.Model.Series.Add(PlotModelDefine.drawFuzzyNumberOrder(fuzzyNumberB, disPara, "Number B")); plotView.Model.Series.Add(PlotModelDefine.drawFuzzyNumberOrder(result, disPara, "Result")); plotView.InvalidatePlot(); } }
private void ButtonMultiply_Click(object sender, RoutedEventArgs e) { plotView.Model.Series.Clear(); FuzzyNumber result; ParseFNTextBoxes(); int disPara; TryParse(textBoxDiscretization.Text, out disPara); FuzzyNumber fuzzyNumberA = new FuzzyNumber(a1, a2, a3, a4, disPara); FuzzyNumber fuzzyNumberB = new FuzzyNumber(b1, b2, b3, b4, disPara); result = FNAlgebra.multiplyAB(fuzzyNumberA, fuzzyNumberB); resultToContinue = result; textBoxOutput.Text = "{ " + result + "}"; var scale = result.findMaxValueOfFuzzyNumber(fuzzyNumberA, fuzzyNumberB, result); PlotModelDefine.ScalePlotOFN(plotView.Model, scale); plotView.Model.Series.Add(PlotModelDefine.drawFuzzyNumber(fuzzyNumberA, disPara, "Number A")); plotView.Model.Series.Add(PlotModelDefine.drawFuzzyNumber(fuzzyNumberB, disPara, "Number B")); plotView.Model.Series.Add(PlotModelDefine.drawFuzzyNumber(result, disPara, "Result")); plotView.Model.Series.Add(PlotModelDefine.drawFuzzyNumberOrder(fuzzyNumberA, disPara, "Number A")); plotView.Model.Series.Add(PlotModelDefine.drawFuzzyNumberOrder(fuzzyNumberB, disPara, "Number B")); plotView.Model.Series.Add(PlotModelDefine.drawFuzzyNumberOrder(result, disPara, "Result")); plotView.InvalidatePlot(); }
public MainPage() { this.InitializeComponent(); comboBoxPartOfPolynomial.Items.Add("Up"); comboBoxPartOfPolynomial.Items.Add("Down"); plotView.Model = PlotModelDefine.ZeroCrossingForOFN(30); ApplicationView.GetForCurrentView().TryEnterFullScreenMode(); var bounds = ApplicationView.GetForCurrentView().VisibleBounds; double scaleFactor = DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel; var size = new Size(bounds.Width * scaleFactor, bounds.Height * scaleFactor); }
private void ButtonChangeMode_Click(object sender, RoutedEventArgs e) { if (isPolynomialMode) { PolynomialFNGrid.Margin = new Thickness(960, 0, 0, 0); PlotViewGrid.Margin = new Thickness(0, 540, 0, 0); plotView.Width = 1920; plotView.Height = 540; PlotViewGrid.Height = 540; PlotViewGrid.Width = 1920; plotView.Model = PlotModelDefine.ZeroCrossingForOFN(30); isPolynomialMode = false; buttonAddPolynomials.IsEnabled = false; buttonSubstractPolynomials.IsEnabled = false; buttonMultiplyPolynomials.IsEnabled = false; buttonDividePolynomials.IsEnabled = false; buttonAdd.IsEnabled = true; buttonSubtract.IsEnabled = true; buttonMultiply.IsEnabled = true; buttonDivide.IsEnabled = true; } else { PolynomialFNGrid.Margin = new Thickness(0, 400, 0, 0); PlotViewGrid.Margin = new Thickness(960, 0, 0, 0); plotView.Width = 960; plotView.Height = 1080; PlotViewGrid.Height = 1080; PlotViewGrid.Width = 960; plotView.Model = PlotModelDefine.ZeroCrossingForPolynomial(30); isPolynomialMode = true; buttonAddPolynomials.IsEnabled = true; buttonSubstractPolynomials.IsEnabled = true; buttonMultiplyPolynomials.IsEnabled = true; buttonDividePolynomials.IsEnabled = true; buttonAdd.IsEnabled = false; buttonSubtract.IsEnabled = false; buttonMultiply.IsEnabled = false; buttonDivide.IsEnabled = false; } }
private void ButtonMultiplyPolynomials_Click(object sender, RoutedEventArgs e) { ParsePolynomialTextBoxes(); PolynomialAlgebra polynomialAlgebra = new PolynomialAlgebra(); Polynomial polynomialResult = new Polynomial(); PolynomialAlgebra algebra = new PolynomialAlgebra(); Polynomial polynomialA = new Polynomial(freeValueA, valueXA, valueX2A, valueX3A, valueX4A, valueX5A, valueX6A, valueX7A, valueX8A, valueX9A, valueX10A); Polynomial polynomialB = new Polynomial(freeValueB, valueXB, valueX2B, valueX3B, valueX4B, valueX5B, valueX6B, valueX7B, valueX8B, valueX9B, valueX10B); polynomialResult = PolynomialAlgebra.multiplyPolynomialAB(polynomialA, polynomialB); int discretizationValue; int.TryParse(textBoxDiscretization.Text.ToString(), out discretizationValue); if (comboBoxPartOfPolynomial.SelectedItem != null) { if (comboBoxPartOfPolynomial.SelectedItem.ToString().Equals("Up")) { for (int i = 0; i < plotView.Model.Series.Count; i++) { if (plotView.Model.Series.ElementAt(i).Title.Equals("Up(Fa+Fb)")) { plotView.Model.Series.RemoveAt(i); } if (plotView.Model.Series.ElementAt(i).Title.Equals("Up(Fa)")) { plotView.Model.Series.RemoveAt(i); } if (plotView.Model.Series.ElementAt(i).Title.Equals("Up(Fb)")) { plotView.Model.Series.RemoveAt(i); } } upValuesOfPolynomials.Clear(); textBoxResultUpPolynomail.Text = polynomialResult.ToString(); plotView.Model.Series.Add(PlotModelDefine.DrawFunction(polynomialResult, "Up(Fa+Fb)", discretizationValue)); plotView.Model.Series.Add(PlotModelDefine.DrawFunction(polynomialA, "Up(Fa)", discretizationValue)); plotView.Model.Series.Add(PlotModelDefine.DrawFunction(polynomialB, "Up(Fb)", discretizationValue)); countUpForAandB(algebra, polynomialA, polynomialB, polynomialResult); upValuesOfPolynomials.Add(polynomialAlgebra.countValueFromFunction(polynomialA, 1)); upValuesOfPolynomials.Add(polynomialAlgebra.countValueFromFunction(polynomialB, 1)); upValuesOfPolynomials.Add(polynomialAlgebra.countValueFromFunction(polynomialResult, 1)); upValuesOfPolynomials.Add(polynomialAlgebra.countValueFromFunction(polynomialA, 0)); upValuesOfPolynomials.Add(polynomialAlgebra.countValueFromFunction(polynomialB, 0)); upValuesOfPolynomials.Add(polynomialAlgebra.countValueFromFunction(polynomialResult, 0)); upValuesOfPolynomials.Sort(); } else { for (int i = 0; i < plotView.Model.Series.Count; i++) { if (plotView.Model.Series.ElementAt(i).Title.Equals("Down(Ga+Gb)")) { plotView.Model.Series.RemoveAt(i); } if (plotView.Model.Series.ElementAt(i).Title.Equals("Down(Ga)")) { plotView.Model.Series.RemoveAt(i); } if (plotView.Model.Series.ElementAt(i).Title.Equals("Down(Gb)")) { plotView.Model.Series.RemoveAt(i); } } downValuesOfPolynomials.Clear(); textBoxResultDownPolynomail.Text = polynomialResult.ToString(); plotView.Model.Series.Add(PlotModelDefine.DrawFunction(polynomialResult, "Down(Ga+Gb)", discretizationValue)); plotView.Model.Series.Add( PlotModelDefine.DrawFunction(polynomialA, "Down(Ga)", discretizationValue)); plotView.Model.Series.Add( PlotModelDefine.DrawFunction(polynomialB, "Down(Gb)", discretizationValue)); countDownforAandB(algebra, polynomialA, polynomialB, polynomialResult); downValuesOfPolynomials.Add(polynomialAlgebra.countValueFromFunction(polynomialA, 1)); downValuesOfPolynomials.Add(polynomialAlgebra.countValueFromFunction(polynomialB, 1)); downValuesOfPolynomials.Add(polynomialAlgebra.countValueFromFunction(polynomialResult, 1)); downValuesOfPolynomials.Add(polynomialAlgebra.countValueFromFunction(polynomialA, 0)); downValuesOfPolynomials.Add(polynomialAlgebra.countValueFromFunction(polynomialB, 0)); downValuesOfPolynomials.Add(polynomialAlgebra.countValueFromFunction(polynomialResult, 0)); downValuesOfPolynomials.Sort(); } } if (upValuesOfPolynomials.Count > 0 && downValuesOfPolynomials.Count > 0) { if (upValuesOfPolynomials[5] >= downValuesOfPolynomials[5]) { plotView.Model.Axes.ElementAt(0).AbsoluteMaximum = upValuesOfPolynomials[5] + 5; plotView.Model.Axes.ElementAt(0).Maximum = upValuesOfPolynomials[5] + 5; } else { plotView.Model.Axes.ElementAt(0).AbsoluteMaximum = downValuesOfPolynomials[5] + 5; plotView.Model.Axes.ElementAt(0).Maximum = downValuesOfPolynomials[5] + 5; } if (upValuesOfPolynomials[0] <= downValuesOfPolynomials[0]) { plotView.Model.Axes.ElementAt(0).AbsoluteMinimum = upValuesOfPolynomials[0] - 5; plotView.Model.Axes.ElementAt(0).Minimum = upValuesOfPolynomials[0] - 5; } else { plotView.Model.Axes.ElementAt(0).AbsoluteMinimum = downValuesOfPolynomials[0] - 5; plotView.Model.Axes.ElementAt(0).Minimum = downValuesOfPolynomials[0] - 5; } } else { if (upValuesOfPolynomials.Count > 0) { plotView.Model.Axes.ElementAt(0).AbsoluteMaximum = upValuesOfPolynomials[5] + 5; plotView.Model.Axes.ElementAt(0).Maximum = upValuesOfPolynomials[5] + 5; plotView.Model.Axes.ElementAt(0).AbsoluteMinimum = upValuesOfPolynomials[0] - 5; plotView.Model.Axes.ElementAt(0).Minimum = upValuesOfPolynomials[0] - 5; } else if (downValuesOfPolynomials.Count > 0) { plotView.Model.Axes.ElementAt(0).AbsoluteMaximum = downValuesOfPolynomials[5] + 5; plotView.Model.Axes.ElementAt(0).Maximum = downValuesOfPolynomials[5] + 5; plotView.Model.Axes.ElementAt(0).AbsoluteMinimum = downValuesOfPolynomials[0] - 5; plotView.Model.Axes.ElementAt(0).Minimum = downValuesOfPolynomials[0] - 5; } } FuzzyNumber res1 = new FuzzyNumber(w1, w2, w3, w4, discretizationValue); resultToContinue = res1; representResult(); plotView.InvalidatePlot(true); }