Пояснительная записка (1234703), страница 6
Текст из файла (страница 6)
p.drawLine(width()/2 + x*cos(h), height()/2 + x*sin(h), width()/2 + x*cos(h - angle), height()/2 + x*sin(h - angle));
nn++;
current.push_back(h);
if(fabs(h) == fabs(arc/2)){
current.push_back(arc);
}
if(h != 0){
mathPrevious.push_back(h/2);
mathPrevious.push_back(arc*3/4);
}
}
else if(h - 3*angle <= arc){
if(tt == 0){
angle = fabs((arc - h)/3);
}
if(fabs(h - angle) > fabs(arc - pi/18000)) break;
p.drawLine(width()/2 + x*cos(h), height()/2 + x*sin(h), width()/2 + x*cos(h - angle), height()/2 + x*sin(h - angle));
current.push_back(h);
mathPrevious.push_back(h - angle/2);
if(tt == 2){
current.push_back(arc);
}
tt++;
}
else{
p.drawLine(width()/2 + x*cos(h), height()/2 + x*sin(h), width()/2 + x*cos(h - angle), height()/2 + x*sin(h - angle));
current.push_back(h);
mathPrevious.push_back(h - angle/2);
}
p.setPen(QPen(Qt::black, 4, Qt::SolidLine));
p.drawPoint(width()/2 + x*cos(h), height()/2 + x*sin(h));
if(i == 0){
p.setPen(QPen(Qt::red, 1, Qt::SolidLine));
p.drawLine(width()/2 + x*cos(h), height()/2 + x*sin(h), width()/2, height()/2);
}
}
int hh = 0;
double backZ = 0;
for(int j = 0; j < halfPrevious.size(); j++){// CYCLE FOR TRIANGULATING NODES
if(i == 0) break;
QVector <double> minimum;
double min = 100;
double minZ = 0;
for(int z = 0; z < current.size(); z++){// CYCLE FOR CALCULATING MIN
minimum.push_back(fabs(halfPrevious[j] - current[z]));
if(min > minimum[z]){
min = minimum[z];
minZ = z;
}
}
int g = minZ;
p.setPen(QPen(Qt::red, 1, Qt::SolidLine));
if( abs( minZ - backZ ) > 1 ) {
p.drawLine(width()/2 + xPrevious*cos(previous[hh]), height()/2 + xPrevious*sin(previous[hh]), width()/2 + x*cos(current[minZ - 1]), height()/2 + x*sin(current[minZ - 1]));
}
backZ = minZ;
p.drawLine(width()/2 + xPrevious*cos(previous[hh]), height()/2 + xPrevious*sin(previous[hh]), width()/2 + x*cos(current[g]), height()/2 + x*sin(current[g]));
p.drawLine(width()/2 + xPrevious*cos(previous[hh + 1]), height()/2 + xPrevious*sin(previous[hh + 1]), width()/2 + x*cos(current[g]), height()/2 + x*sin(current[g]));
hh++;
}
}
}
void MainWindow::on_lineEdit_textChanged(const QString &arg1)
{
ui->centralWidget->repaint();
}
void MainWindow::on_lineEdit_2_textChanged(const QString &arg1)
{
ui->centralWidget->repaint();
}
void MainWindow::on_lineEdit_3_textChanged(const QString &arg1)
{
ui->centralWidget->repaint();
}
49















