Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void button7_Click(object sender, EventArgs e)
- {
- ClearForm();
- PreparareForm(-11, 11, -11, 11);
- Random r = new Random();
- int n = r.Next(3, 20);
- int m = r.Next(3, n);
- XMid = chart1.Series.Add("Points");
- XMid.ChartType = SeriesChartType.Point;
- List<int> xx = new List<int>();
- List<int> yy = new List<int>();
- for (int i = 0; i < n; i++)
- {
- int x = r.Next(-10, 10);
- int y = r.Next(-10, 10);
- richTextBox1.AppendText("x: " + x + " y: " + y + "\n");
- XMid.Points.AddXY(x, y);
- xx.Add(x);
- yy.Add(y);
- }
- X1X2 = chart1.Series.Add("Other Points");
- X1X2.ChartType = SeriesChartType.Point;
- int count = 0;
- for (int i = 0; i < m; i++)
- {
- double ave = vidutinis(xx, yy);
- other_points(X1X2, ave, xx, yy, count);
- count++;
- }
- //richTextBox1.AppendText("\n" + ave);
- }
- private void other_points(Series xx, double ave, List<int> x, List<int> y, int count)
- {
- if (count < 10)
- xx.Points.AddXY(x[count] + ave, y[count] - ave*2);
- if (count > 10)
- xx.Points.AddXY(x[count] - ave, y[count] + ave);
- }
- private double vidutinis(List<int> x, List<int> y)
- {
- double a = 0;
- for (int i = 0; i < x.Count; i++)
- {
- for (int k = 0; k < y.Count; k++)
- {
- if (i != k)
- a += Math.Pow((Math.Pow((x[k] - x[i]), 2) + Math.Pow((y[k] - y[i]), 2)), 1 / 2);
- }
- }
- double ave = a / (x.Count * y.Count);
- return ave;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement