Form1.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using GenDanDoZad;
  2. using System;
  3. using System.Windows.Forms;
  4. namespace _08_Interpolacja
  5. {
  6. public partial class Form1 : Form
  7. {
  8. public Form1()
  9. {
  10. InitializeComponent();
  11. }
  12. double a, b;
  13. int stopien, licznosc, licznosc2;
  14. double[][] XY;
  15. Generator generator = new Generator();
  16. ChartForm chartForm = new ChartForm();
  17. Interpolacja interpol = new Interpolacja();
  18. double[][] xy = new double[2][];
  19. void CzytajDane()
  20. {
  21. a = double.Parse(textBox1.Text);
  22. b = double.Parse(textBox2.Text);
  23. stopien = int.Parse(textBox3.Text);
  24. licznosc = int.Parse(textBox4.Text);
  25. licznosc2 = int.Parse(textBox5.Text);
  26. }
  27. private void button1_Click(object sender, EventArgs e)
  28. {
  29. chartForm.Clear();
  30. CzytajDane();
  31. XY = generator.PolyM(a, b, stopien, licznosc);
  32. ChartForm.ShowPoints(XY[0], XY[1], $"Poly-{stopien}");
  33. }
  34. private void button2_Click(object sender, EventArgs e)
  35. {
  36. xy[0] = new double[licznosc2];
  37. xy[1] = new double[licznosc2];
  38. double dx = (b - a) / (licznosc2 - 1);
  39. for (int i = 0; i < licznosc2; i++)
  40. {
  41. xy[0][i] = a + i * dx;
  42. xy[1][i] = interpol.WielLagr1(XY[0], XY[1], xy[0][i]);
  43. }
  44. ChartForm.ShowLines(xy[0], xy[1], "intWielLagr1");
  45. }
  46. private void button3_Click(object sender, EventArgs e)
  47. {
  48. xy[0] = new double[licznosc2];
  49. xy[1] = new double[licznosc2];
  50. double dx = (b - a) / (licznosc2 - 1);
  51. for (int i = 0; i < licznosc2; i++)
  52. {
  53. xy[0][i] = a + i * dx;
  54. xy[1][i] = interpol.WielLagr2(XY[0], XY[1], xy[0][i]);
  55. }
  56. ChartForm.ShowLines(xy[0], xy[1], "intWielLagr2");
  57. }
  58. private void button4_Click(object sender, EventArgs e)
  59. {
  60. }
  61. }
  62. }