-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
345 lines (320 loc) · 11.2 KB
/
main.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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
#include<iostream>
#include "Element.h"
#include "Point.h"
#include "Vector.h"
#include "VectorLengthException.h"
#include "Triangle.h"
#include "EqualPointException.h"
#include "Line.h"
#include "Segment.h"
#include "Tetrahedron.h"
#include <fstream>
using namespace std;
int main() {
ofstream myfile;
myfile.open("myFile.txt", ios::out);
if (!myfile) {
cerr << "File could not be opened!\n";
return 1;
}
setlocale(LC_ALL, "Bulgarian");
Point p1;
Point p2;
unsigned menu;
cout << "Please select a geometric object: \n"
<< "1 – Point \n"
<< "2 – Vector \n"
<< "3 – Line \n"
<< "4 – Segment \n"
<< "5 – Triange \n"
<< "6 - Tetrahedron \n";
myfile << "Please select a geometric object: \n"
<< "1 – Point \n"
<< "2 – Vector \n"
<< "3 – Line \n"
<< "4 – Segment \n"
<< "5 – Triange \n"
<< "6 - Tetrahedron \n";
Vector a;
Vector b;
Vector c;
Vector g;
Triangle y;
Line line1(Point(3,3,3), Vector(1,2,3));
Line line2(Point(3,3,3), Vector(5,8,2));
Line line3(Point(19, 24, 29), Point(31, 36, 41));
Point point(19, 24, 29);
//cout << "a " << boolalpha << line3 + point;
//cout << "b " << boolalpha << line1 | line2;
//cout << "c " << boolalpha << line1 || line2;
//Segment segm(Point(7,12,2), Vector(2,9,4), Point(0,0,0), Point(1,1,1));
Tetrahedron tetr;
char ch;
do {
cin >> menu;
switch (menu) {
case 1:
cin >> p1;
cout << endl;
myfile << p1 << endl;
cin >> p2;
myfile << p2 << endl;
cout << boolalpha << (p1 == p2) << endl;
myfile << boolalpha << (p1 == p2) << endl;
break;
case 2: unsigned menu2;
cin >> a;
myfile << a << endl;
cout << "Please select an operation for the object: \n"
<< "1 - vector length calculation \n"
<< "2 - vector direction calculation \n"
<< "3 - projection of a vector onto another vector \n"
<< "4 - zero vector check \n"
<< "5 - check for parallelism of two vectors \n"
<< "6 - check for perpendicularity of two vectors \n"
<< "7 - addition of two vectors \n"
<< "8 - multiplication of a vector by a real number \n"
<< "9 - dot product of two vectors \n"
<< "10 - cross product of two vectors \n"
<< "11 - mixed product of three vectors \n";
myfile << "Please select an operation for the object: \n"
<< "1 - vector length calculation \n"
<< "2 - vector direction calculation \n"
<< "3 - projection of a vector onto another vector \n"
<< "4 - zero vector check \n"
<< "5 - check for parallelism of two vectors \n"
<< "6 - check for perpendicularity of two vectors \n"
<< "7 - addition of two vectors \n"
<< "8 - multiplication of a vector by a real number \n"
<< "9 - dot product of two vectors \n"
<< "10 - cross product of two vectors \n"
<< "11 - mixed product of three vectors \n";
char ch2;
do {
cin >> menu2;
switch (menu2) {
case 1: cout << "Length = " << a.lengthOfVec() << endl;
myfile << "Length = " << a.lengthOfVec() << endl;
break;
case 2: cout << "Direction = " << a.dirOfVec() << endl;
myfile << "Direction = " << a.dirOfVec() << endl;
break;
case 3: cin >> b;
myfile << b << endl;
cout << "Projection = " << a.proj(b) << endl;
myfile << "Projection = " << a.proj(b) << endl;
break;
case 4:
cout << "Zero vector check -> " << boolalpha << a.checkIfNull() << endl;
myfile << "Zero vector check -> " << boolalpha << a.checkIfNull() << endl;
break;
case 5: cin >> b;
myfile << b << endl;
cout << "Check for parallelism: " << boolalpha << a.checkifParallel(b) << endl;
myfile << "Check for parallelism: " << boolalpha << a.checkifParallel(b) << endl;
break;
case 6: cin >> b;
myfile << b << endl;
cout << "Check for perpendicularity: " << boolalpha << a.checkIfPerpend(b) << endl;
myfile << "Check for perpendicularity: " << boolalpha << a.checkIfPerpend(b) << endl;
break;
case 7: cin >> b;
myfile << b << endl;
cout << "Result of addition: " << a + b << endl;
myfile << "Result of addition: " << a + b << endl;
break;
case 8: int num;
cout << "Enter a real number: ";
cin >> num;
myfile << num << endl;
cout << "Result of multiplication: " << a * num << endl;
myfile << "Result of multiplication: " << a * num << endl;
break;
case 9: cin >> b;
myfile << b << endl;
cout << "Dot product result: " << a * b << endl;
myfile << "Dot product result: " << a * b << endl;
break;
case 10: cin >> b;
myfile << b << endl;
g = a ^ b;
cout << "Cross product result: " << g << endl;
myfile << "Cross product result: " << g << endl;
break;
case 11: cin >> b;
myfile << b << endl;
cin >> c;
myfile << c << endl;
cout << "Mixed product: " << a(b,c) << endl;
myfile << "Mixed product: " << a(b,c) << endl;
break;
}
cout << "Do you want to select a new operation (y/n)?";
myfile << "Do you want to select a new operation (y/n)?";
cin >> ch2;
myfile << ch2 << endl;
} while (ch2 != 'n');
break;
case 3: unsigned menu3;
cout << "Please select an operation for the object: \n"
<< "1 - to find the direction of the line - returns a vector parallel to the line \n"
<< "2 - to find a normal vector - returns a vector perpendicular to the line \n"
<< "3 - to find the angle between two lines - returns the value of the angle in radians \n";
myfile << "Please select an operation for the object: \n"
<< "1 - to find the direction of the line - returns a vector parallel to the line \n"
<< "2 - to find a normal vector - returns a vector perpendicular to the line \n"
<< "3 - to find the angle between two lines - returns the value of the angle in radians \n";
char ch3;
do {
cin >> menu3;
myfile << menu3 << endl;
switch (menu3) {
case 1:
cout << "Direction of the line = ";
a = line1.getDirection();
cout << a;
cout << endl;
//myfile << "Direction of the line = " << line1.getDirection() << endl;
break;
case 2:
a = line1.normalVector();
cout << "Normal vector = " << a << endl;
myfile << "Normal vector = " << a << endl;
break;
case 3:
cout << "The angle between two lines = " << line1.getAngle(line2) << endl;
myfile << "The angle between two lines = " << line1.getAngle(line2) << endl;
break;
}
cout << "Do you want to select a new operation (y/n)?";
myfile << "Do you want to select a new operation (y/n)?";
cin >> ch3;
myfile << ch3 << endl;;
} while (ch3 != 'n');
break;
case 4: unsigned menu4;
cout << "Please select an operation for the object: \n"
<< "1 - to find the length of a segment that returns a positive real number \n"
<< "2 - to find the middle of a segment that returns a point with coordinates \n";
myfile << "Please select an operation for the object: \n"
<< "1 - to find the length of a segment that returns a positive real number \n"
<< "2 - to find the middle of a segment that returns a point with coordinates \n";
char ch4;
do {
cin >> menu4;
myfile << menu4;
switch (menu4) {
case 1:
cout << "The length of a segment = ";//<< segm.getLengthOfSegm() << endl;
break;
case 2:
cout << "The middle of a segment = ";// << segm.getMiddleOfSegm() << endl;
break;
}
cout << "Do you want to select a new operation (y/n)?";
myfile << "Do you want to select a new operation (y/n)?";
cin >> ch4;
myfile << ch4 << endl;
} while (ch4 != 'n');
break;
case 5: unsigned menu5;
cout << "Please select an operation for the object: \n"
<< "1 - determine the type of triangle \n"
<< "2 - determine the area of triangle \n"
<< "3 - determine the perimeter of triangle \n"
<< "4 - finding the medicenter of the triangle by returning a Point object \n";
myfile << "Please select an operation for the object: \n"
<< "1 - determine the type of triangle \n"
<< "2 - determine the area of triangle \n"
<< "3 - determine the perimeter of triangle \n"
<< "4 - finding the medicenter of the triangle by returning a Point object \n";
char ch5;
do {
cin >> menu5;
myfile << menu5 << endl;
switch (menu5) {
case 1:
cin >> y;
myfile << y << endl;
y.kindOfTriangle();
break;
case 2:
cin >> y;
myfile << y << endl;
myfile << "Area = " << y.area() << endl;
cout << "Area = " << y.area() << endl;
break;
case 3:
cin >> y;
myfile << y << endl;
cout << "Perimeter = " << y.perimeter() << endl;
myfile << "Perimeter = " << y.perimeter() << endl;
break;
case 4:
cin >> y;
myfile << y << endl;
cout << "Medicenter = " << y.medicenter() << endl;
myfile << "Medicenter = " << y.medicenter() << endl;
break;
}
cout << "Do you want to select a new operation (y/n)?";
myfile << "Do you want to select a new operation (y/n)?";
cin >> ch5;
myfile << ch5 << endl;
} while (ch5 != 'n');
break;
case 6: unsigned menu6;
cout << "Please select an operation for the object: \n"
<< "1 - to check that it is regular (all edges are equal) \n"
<< "2 - to check that it is orthogonal (every two opposite edges are perpendicular) \n"
<< "3 - to find the surrounding surface \n"
<< "4 - to find volume \n";
myfile << "Please select an operation for the object: \n"
<< "1 - to check that it is regular (all edges are equal) \n"
<< "2 - to check that it is orthogonal (every two opposite edges are perpendicular) \n"
<< "3 - to find the surrounding surface \n"
<< "4 - to find volume \n";
char ch6;
do {
cin >> menu6;
myfile << menu6 << endl;
switch (menu6) {
case 1:
cin >> tetr;
myfile << tetr << endl;
cout << "Is the tetrahedron regular? " << boolalpha << tetr.pravilen() << endl;
myfile << "Is the tetrahedron regular? " << boolalpha << tetr.pravilen() << endl;
break;
case 2:
cin >> tetr;
myfile << tetr << endl;
cout << "Is the tetrahedron orthogonal? " << boolalpha << tetr.ortogonalen() << endl;
myfile << "Is the tetrahedron orthogonal? " << boolalpha << tetr.ortogonalen() << endl;
break;
case 3:
cin >> tetr;
myfile << tetr << endl;
cout << "Surrounding surface = " << tetr.surroundingArea() << endl;
break;
case 4:
cin >> tetr;
myfile << tetr << endl;
cout << "Volume = " << tetr.capacity() << endl;
myfile << "Volume = " << tetr.capacity() << endl;
break;
}
cout << "Do you want to select a new operation (y/n)?";
myfile << "Do you want to select a new operation (y/n)?";
cin >> ch6;
myfile << ch6 << endl;
} while (ch6 != 'n');
break;
}
cout << "Do you want to select a new geometric object(y/n)?";
myfile << "Do you want to select a new geometric object(y/n)?";
cin >> ch;
myfile << ch << endl;
} while (ch != 'n');
myfile.close();
return 0;
}