-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTetrahedron.cpp
126 lines (113 loc) · 2.88 KB
/
Tetrahedron.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
#include "Tetrahedron.h"
#include<iostream>
#include "EqualPointException.h"
#include<exception>
Tetrahedron::Tetrahedron()
{
}
Tetrahedron::Tetrahedron(const Point & a, const Point & b, const Point & c, const Point & d)
{
try {
if (a == b) {
std::cout << "First: " << a << " and " << "second point: " << b << std::endl;
throw EqualPointException();
}
else if (a == c) {
std::cout << "First: " << a << " and " << "third point: " << c << std::endl;
throw EqualPointException();
}
else if (b == c) {
std::cout << "Second: " << b << " and " << "third point: " << c << std::endl;
throw EqualPointException();
}
else if (a == d) {
std::cout << "First: " << a << " and " << "forth point: " << d << std::endl;
throw EqualPointException();
}
else if (b == d) {
std::cout << "Second: " << b << " and " << "forth point: " << d << std::endl;
throw EqualPointException();
}
else if (c == d) {
std::cout << "Third: " << c << " and " << "forth point: " << d << std::endl;
throw EqualPointException();
}
else {
this->A = a;
this->B = b;
this->C = c;
this->D = d;
}
}
catch (EqualPointException& e)
{
std::cout << e.what() << std::endl;
}
}
Tetrahedron::Tetrahedron(const Tetrahedron & rhs)
{
A = rhs.A;
B = rhs.B;
C = rhs.C;
D = rhs.D;
}
Tetrahedron::~Tetrahedron()
{
}
bool Tetrahedron::pravilen() const
{
Vector v1(A, B);
Vector v2(A, C);
Vector v3(B, C);
Vector v4(A, D);
Vector v5(B, D);
Vector v6(C, D);
double a = v1.lengthOfVec();
double b = v2.lengthOfVec();
double c = v3.lengthOfVec();
double d = v4.lengthOfVec();
double e = v4.lengthOfVec();
double f = v4.lengthOfVec();
if (a == b == c == d == e == f) return true;
return false;
}
bool Tetrahedron::ortogonalen()const {
if (((this->A.x * C.x) + (this->A.y * C.y) + (this->A.z * C.z)) == 0) {
return true;
}
else if (((this->B.x * D.x) + (this->B.y * D.y) + (this->B.z * D.z)) == 0) {
return true;
}
else
return false;
}
double Tetrahedron::surroundingArea() const
{
//ïðàâèëåí òåòðàåäúð
Vector v1(A, B);
double a = v1.lengthOfVec();
return sqrt(3 * (pow(a, 2)));;
}
double Tetrahedron::capacity()const {
//ïðàâèëåí òåòðàåäúð
Vector v1(A, B);
double a = v1.lengthOfVec();
double res = (1 / 12) * sqrt(2 * (a * a * a));
return res;
}
std::ostream & operator<<(std::ostream & out, const Tetrahedron & rhs)
{
return out << "Point A: " << rhs.A << "Point B: " << rhs.B << "Point C: " << rhs.C << "Point D: " << rhs.D;
}
std::istream & operator>>(std::istream & in, Tetrahedron & rhs)
{
std::cout << "Please enter first point \n";
in >> rhs.A;
std::cout << "Please enter second point \n";
in >> rhs.B;
std::cout << "Please enter third point \n";
in >> rhs.C;
std::cout << "Please enter forth point \n";
in >> rhs.D;
return in;
}