private void GetAngle(object sender, EventArgs e) { g.ResetTransform(); g = picture.CreateGraphics(); g.SmoothingMode = SmoothingMode.HighQuality; drawingState.X = (double)Xnum.Value; drawingState.Fi = (double)FInum.Value; drawingState.Y = (double)YNum.Value; DefuzzificationMethod method = DefuzzificationMethod.GravityCentre; if (methodComboBox.SelectedIndex >= 0) { method = (DefuzzificationMethod)Enum.Parse(typeof(DefuzzificationMethod), methodComboBox.SelectedItem.ToString()); } Stopwatch sw = new Stopwatch(); sw.Start(); double teta = task.GetAngle(drawingState.X, drawingState.Fi, method); Tetanum.Value = double.IsNaN(teta)? 0: (decimal)teta; drawingState.Teta = (double)Tetanum.Value; sw.Stop(); label7.Text = sw.ElapsedMilliseconds.ToString(); g.Clear(Color.White); drawingState.Draw(g); }
private void btnStart_Click(object sender, EventArgs e) { double x = double.Parse(textBoxX.Text); double fi = double.Parse(textBoxFi.Text) / Math.PI; double y = double.Parse(textBoxY.Text); chart.Series[0].Points.Clear(); double teta = 0; while ((x <= 150 && x >= -150) && (y >= 0 && y <= 300)) { chart.Series[0].Points.AddXY(x, y); chart.Refresh(); teta = task.GetAngle(x, fi * Math.PI) / Math.PI; x = x + Math.Sin(fi + teta) - Math.Sin(fi) * Math.Cos(teta); y = y - Math.Sin(fi + teta) - Math.Sin(fi) * Math.Sin(teta); fi = fi - Math.Asin((2 * Math.Sin(teta)) / 20); } }