C++ (Qt)void Widget::getResult(){ QLine line0,line1;int k=0;line0.setP1(QPoint(x[0],y[0]));line1.setP1(QPoint(x[1],y[1])); for(int i=0;i<10000;i++){ ...................///////////////////////////////////// тут я вычисляю новые координаты и скорость ///////////////////////////////////////.................. if(k==50){ /// тут я рисую траекторию line0.setP2(QPoint(x[0],y[0])); line1.setP2(QPoint(x[1],y[1])); scene->addLine(line0,QPen(QBrush(Qt::red),5,Qt::SolidLine)); scene->addLine(line1,QPen(QBrush(Qt::blue),5,Qt::SolidLine)); line0.setP1(QPoint(x[0],y[0])); line1.setP1(QPoint(x[1],y[1])); k=0;}//if k++;}//for }//getResult
C++ (Qt)void Widget::getResult(){ int k=0;line0.setP1(QPointF(x[0],y[0]));line1.setP1(QPointF(x[1],y[1])); timer->start(100);int N=10000; for(int i=0;i<N;i++){ dt=ui->lineEdit_dt->text().toDouble(); fx=x[1]-x[0]; fy=y[1]-y[0]; r=sqrt(pow(fx,2)+pow(fy,2)); vx[0]+=-Kraft(sqrt(pow(fx,2)+pow(fy,2)))*(fx/r)*dt/m[0]; vy[0]+=-Kraft(sqrt(pow(fx,2)+pow(fy,2)))*(fy/r)*dt/m[0]; vx[1]+=Kraft(sqrt(pow(fx,2)+pow(fy,2)))*(fx/r)*dt/m[1]; vy[1]+=Kraft(sqrt(pow(fx,2)+pow(fy,2)))*(fy/r)*dt/m[1]; x[0]+=vx[0]*dt; y[0]+=vy[0]*dt; x[1]+=vx[1]*dt; y[1]+=vy[1]*dt; k++; if(k=100){k=0; QEventLoop *loop=new QEventLoop; QTimer *t=new QTimer; t->start(1); loop->connect(t,SIGNAL(timeout()),loop,SLOT(quit())); loop->exec();}//if k }//for }//getResult