Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.38 KB | None | 0 0
  1. void MainWindow::on_lineEditA_textChanged(QString str)
  2. {
  3.     eq1.a.set(str);
  4. }
  5.  
  6. void MainWindow::on_lineEditB_textChanged(QString str)
  7. {
  8.     eq1.b.set(str);
  9. }
  10.  
  11.  
  12. void MainWindow::on_lineEditC_textChanged(QString str)
  13. {
  14.     eq1.c.set(str);
  15. }
  16.  
  17. void MainWindow::on_lineEditD_textChanged(QString str)
  18. {
  19.     eq1.d.set(str);
  20. }
  21.  
  22. void MainWindow::on_lineEditE_textChanged(QString str)
  23. {
  24.     eq1.e.set(str);
  25. }
  26.  
  27. void MainWindow::on_lineEditF_textChanged(QString str)
  28. {
  29.     eq1.f.set(str);
  30. }
  31.  
  32. void MainWindow::on_lineEditA_2_textChanged(QString str)
  33. {
  34.     eq2.a.set(str);
  35. }
  36.  
  37. void MainWindow::on_lineEditB_2_textChanged(QString str)
  38. {
  39.     eq2.b.set(str);
  40. }
  41.  
  42. void MainWindow::on_lineEditC_2_textChanged(QString str)
  43. {
  44.     eq2.c.set(str);
  45. }
  46.  
  47. void MainWindow::on_lineEditD_2_textChanged(QString str)
  48. {
  49.     eq2.d.set(str);
  50. }
  51.  
  52. void MainWindow::on_lineEditE_2_textChanged(QString str)
  53. {
  54.     eq2.e.set(str);
  55. }
  56.  
  57. void MainWindow::on_lineEditF_2_textChanged(QString str)
  58. {
  59.     eq2.f.set(str);
  60. }
  61.  
  62. double f1(double a1, double b1, double c1, double d1, double e1, double f1, double x, double y)
  63. {
  64.     return a1x^2 + b1xy + c1y^2 + d1x + e1y + f1;
  65. }
  66.  
  67. double f2(double a2, double b2, double c2, double d2, double e2, double f2, double x, double y)
  68. {
  69.     return a2x^2 + b2xy + c2y^2 + d2x + e2y + f2;
  70. }
  71.  
  72. double f1_x(double a1, double b1, double d1, double x, double y)
  73. {
  74.     return a1x + b1y + d1;
  75. }
  76.  
  77. double f1_y(double b1, double c1, double e1, double x, double y)
  78. {
  79.     return b1x + c1y + e1;
  80. }
  81.  
  82. double f2_x(double a2, double b2, double d2, double x, double y)
  83. {
  84.     return a2x + b2y + d2;
  85. }
  86.  
  87. double f2_y(double b2, double c2, double e2, double x, double y)
  88. {
  89.     return b2x + c2y + e2;
  90. }
  91.  
  92. int XPEHOBmain()
  93. {
  94.     double W = 0, D1 = 0, D2 = 0, x = 0.5, y = 0.5, E = 0.001, xk = 0, yk = 0;
  95.     int _count = 0;
  96.  
  97.     while (_count < 32000)
  98.     {
  99.         W = f1_x(a1,b1,d1,x,y)*f2_y(b2,c2,e2,x,y) - f2_x(a2,b2,d2,x,y)*f1_y(b1,c1,e1,x,y);
  100.         D1 = f1(a1,b1,c1,d1,e1,f1,x,y)*f2_y(b2,c2,e2,x,y) - f2(a2,b2,c2,d2,e2,f2,x,y)*f1_y(b1,c1,e1,x,y);
  101.         D2 = f2(a2,b2,c2,d2,e2,f2,x,y)*f1_x(a1,b1,d1,x,y) - f1(a1,b1,c1,d1,e1,f1,x,y)*f2_x(a2,b2,d2,x,y);
  102.         if (W == 0)
  103.         {
  104.             qDebug() << "error";//why??
  105.             break;
  106.         }
  107.        
  108.         xk = x - D1/W;
  109.         yk = y - D2/W;
  110.  
  111.         if ((abs(x-xk)+abs(y-yk)) <= E)
  112.         {
  113.             qDebug() << "Done!";
  114.             break;
  115.         }
  116.         else
  117.         {
  118.             x = xk;
  119.             y = yk;
  120.             _count++;
  121.         }
  122.     }
  123.  
  124.     return 0;
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement