-
Notifications
You must be signed in to change notification settings - Fork 0
/
dialogabouttestmatrix.cpp
executable file
·161 lines (149 loc) · 5.54 KB
/
dialogabouttestmatrix.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#include <math.h>
#include <QMessageBox>
#include "dialogabouttestmatrix.h"
#include "helpfunction.h"
#include "ui_dialogabouttestmatrix.h"
DialogAboutTestMatrix::DialogAboutTestMatrix(QWidget *parent) :
QDialog(parent),
_ui(new Ui::DialogAboutTestMatrix)
{
_ui->setupUi(this);
for (int i = 0; i < SIZE; i++) _U[i] = 0;
for (int i = 0; i < ORD; i++) _U[i+ORD*i] = 1; // E-matrix
connect(_ui->applyButton, SIGNAL(clicked()), this, SLOT(apply()));
connect(_ui->clearButton, SIGNAL(clicked()), this, SLOT(clearEnter()));
}
DialogAboutTestMatrix::~DialogAboutTestMatrix()
{
delete _ui;
}
void DialogAboutTestMatrix::accept()
{
apply();
emit readyTestMatrix(_U);
close();
}
void DialogAboutTestMatrix::apply()
{
double W[SIZE] = { 0 };
for (int i = 0; i < ORD; i++)
W[i*ORD+i] = 1;
double V[SIZE] = { 0 };
double ox = 1, oy = 1, oz = 1;
double angle = 0;
if(_ui->homothetyRadioButton->isChecked())
{
qDebug("Homothety was selected");
if(_ui->homothetyOxCheckBox->isChecked())
{
ox = _ui->homothetyOxEdit->text().toInt();
if (ox == 0)
{
QMessageBox::about(0, QObject::tr("Коэффициент подобия равен нулю!"),
QObject::tr("Коэффициент подобия по оси OX равен нулю!"));
return;
}
if(_ui->homothetyCompressionOxCheckBox->isChecked()) ox = 1/ox;
}
if(_ui->homothetyOyCheckBox->isChecked())
{
oy = _ui->homothetyOyEdit->text().toInt();
if (oy == 0)
{
QMessageBox::about(0, tr("Коэффициент подобия равен нулю!"),
tr("Коэффициент подобия по оси OY равен нулю!"));
return;
}
if(_ui->homothetyCompressionOyCheckBox->isChecked()) oy = 1/oy;
}
if(_ui->homothetyOzCheckBox->isChecked())
{
oy = _ui->homothetyOzEdit->text().toInt();
if (oy == 0)
{
QMessageBox::about(0, tr("Коэффициент подобия равен нулю!"),
tr("Коэффициент подобия по оси OZ равен нулю!"));
return;
}
if(_ui->homothetyCompressionOzCheckBox->isChecked()) oz = 1/oz;
}
}
if(_ui->symmetryRadioButton->isChecked())
{
qDebug("Symmetry was selected");
if(_ui->symmetryOxCheckBox->isChecked()) ox *= -1;
if(_ui->symmetryOyCheckBox->isChecked()) oy *= -1;
if(_ui->symmetryOzCheckBox->isChecked()) oz *= -1;
}
for (int i = 0; i < ORD; i++)
{
W[i*ORD] *= ox;
W[i*ORD+1] *= oy;
W[i*ORD+2] *= oz;
}
if(_ui->turningRadioButton->isChecked())
{
qDebug("Turning was selected");
angle = _ui->turningAngleEdit->text().toDouble(); //в градусах
angle = (angle*M_PI)/180; //в радианах
// вокруг оси Oz
if (_ui->turningOxyRadioButton->isChecked()) {
W[0] = W[ORD+1] = cos(angle);
W[1] = -sin(angle);
W[ORD] = sin(angle);
W[2*ORD+2] = 1;
}
// вокруг оси Oy
if (_ui->turningOxzRadioButton->isChecked()) {
W[0] = W[2*ORD+2] = cos(angle);
W[2*ORD] = -sin(angle);
W[ORD+2] = sin(angle);
W[ORD+1] = 1;
}
// вокруг оси Ox
if (_ui->turningOyzRadioButton->isChecked()) {
W[2*ORD+2] = W[ORD+1] = cos(angle);
W[ORD+2] = -sin(angle);
W[2*ORD+1] = sin(angle);
W[0] = 1;
}
}
// V = W*_U поскольку применяется сначала _U, потом W
for (int i = 0; i < ORD; i++)
for (int j = 0; j < ORD; j++)
for (int k = 0; k < ORD; k++)
V[i*ORD+j] = W[i*ORD+k]*_U[k*ORD+j];
// _U = V
for(int i = 0; i < SIZE; i++) _U[i] = V[i];
QMessageBox::about(
0, tr("Test Matrix"),
HelpFunction::showMatrix(_U);
);
qDebug("Ready Test Matrix");
}
void DialogAboutTestMatrix::clearEnter()
{
_ui->homothetyRadioButton->setChecked(false);
_ui->homothetyOxCheckBox->setChecked(false);
_ui->homothetyOyCheckBox->setChecked(false);
_ui->homothetyOzCheckBox->setChecked(false);
_ui->homothetyCompressionOxCheckBox->setChecked(false);
_ui->homothetyCompressionOyCheckBox->setChecked(false);
_ui->homothetyCompressionOzCheckBox->setChecked(false);
_ui->homothetyOxEdit->setText("1");
_ui->homothetyOyEdit->setText("1");
_ui->homothetyOzEdit->setText("1");
_ui->symmetryRadioButton->setChecked(false);
_ui->symmetryOxCheckBox->setChecked(false);
_ui->symmetryOyCheckBox->setChecked(false);
_ui->symmetryOzCheckBox->setChecked(false);
_ui->translationRadioButton->setChecked(false);
_ui->translationXEdit->setText("0");
_ui->translationYEdit->setText("0");
_ui->translationZEdit->setText("0");
_ui->turningRadioButton->setChecked(false);
_ui->turningOxyRadioButton->setChecked(false);
_ui->turningOxzRadioButton->setChecked(false);
_ui->turningOyzRadioButton->setChecked(false);
_ui->turningAngleEdit->setText("0");
}