-
Notifications
You must be signed in to change notification settings - Fork 0
/
Matrix3D.h
executable file
·194 lines (164 loc) · 5.65 KB
/
Matrix3D.h
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
/**
* Class Matrix3D header
* Created by Liad Elidan, 203380050, user:sharon1832
*/
#ifndef EX1_MATRIX3D_H
#define EX1_MATRIX3D_H
#include "Vector3D.h"
#include "iostream"
class Matrix3D
{
private:
Vector3D _vector1;
Vector3D _vector2;
Vector3D _vector3;
public:
/**
* Default constructor zeros all the matrix.
*/
Matrix3D();
/**
* Constructor the receives a number and put diagonal and zeros
* in the rest of the places of the matrix.
* @param x, double the number to be put diagnoaly.
*/
explicit Matrix3D(double x);
/**
* Constrcutor that receives 9 numbers and build a matrix from them.
* @param x1, double.
* @param y1, double.
* @param z1, double.
* @param x2, double.
* @param y2, double.
* @param z2, double.
* @param x3, double.
* @param y3, double.
* @param z3, double.
*/
explicit Matrix3D(double x1, double y1, double z1, double x2, double y2,
double z2, double x3, double y3, double z3);
/**
* Constructor that receives an array of size 9 to build a matrix from.
* @param arr, double array of size 9.
*/
explicit Matrix3D(double arr[9]);
/**
* Constructor that receives an [][] form array of size 3X3 and builds a matrix from it.
* @param arr, double[][] array of size 3X3.
*/
explicit Matrix3D(double arr[3][3]);
/**
* Constructor that recieves 3 Vector3D objects and builds a matrix from them/
* @param other1, Vector3D object.
* @param other2, Vector3D object.
* @param other3, Vector3D object.
*/
Matrix3D(Vector3D other1, Vector3D other2, Vector3D other3);
/**
* Copy constructor.
*/
Matrix3D (const Matrix3D&);
/**
* Overloading "+=" operator between two matrixs, adding them.
* @param other, Matrix3D& object.
* @return Matrix3D& object which is the matrix after the "+=" operator.
*/
Matrix3D& operator+=(const Matrix3D& other);
/**
* Overloading "-=" operator between two matrixs, subtracting them.
* @param other, Matrix3D& object.
* @return Matrix3D& object which is the matrix after the "-=" operator.
*/
Matrix3D& operator-=(const Matrix3D& other);
/**
* Overloading "*=" operator between two matrixs, multiplying them.
* @param other, Matrix3D& object.
* @return Matrix3D object which is the matrix after the "*=" operator.
*/
Matrix3D operator*=(Matrix3D& other);
/**
* Overloading "*" operator between two matrixs, multiplying them.
* @param other, Matrix3D& object.
* @return Matrix3D object which is the matrix after the "*" operator.
*/
Matrix3D operator*(Matrix3D& other);
/**
* Overloading "+" operator between two matrixs, adding between them.
* @param other, Matrix3D& object.
* @return Matrix3D object which is the matrix after the "+" operator.
*/
Matrix3D operator+(const Matrix3D& other);
/**
* Overloading "-" operator between two matrixs, subtracting them.
* @param other, Matrix3D& object.
* @return Matrix3D object which is the matrix after the "-" operator.
*/
Matrix3D operator-(const Matrix3D& other);
/**
* Overloading "*=" operator between a matrix and a number, multiplying them.
* @param other, double& number.
* @return Matrix3D object which is the matrix after the "*=" operator.
*/
Matrix3D operator*=(const double& other);
/**
* Overloading "/=" operator between a matrix and a number, dividing them.
* @param other, double& number.
* @return Matrix3D& object which is the matrix after the "/=" operator.
*/
Matrix3D operator/=(const double& other);
/**
* Overloading "*" operator between a matrix and a vector, multiplying them.
* @param other, Vector3D& object.
* @return Vector3D object which is the vector after the "*" operator.
*/
Vector3D operator*( Vector3D& other);
/**
* Overloading "[]" of a matrix.
* @param index, an int number which is the index in the array of the vector.
* @return Vector3D&&, which has the appropriate vector.
*/
Vector3D& operator[](const int &index);
/**
* Overloading "=" between two matrixs.
* @param other, Matrix3D& object.
* @return Matrix3D& which is a copy of the vector received.
*/
Matrix3D& operator=(const Matrix3D& other);
/**
* Overloading "<<" of a matrix.
* @param out, std::ostream& object.
* @param matrix, Matrix3D& object.
* @return std::ostream& used in the output.
*/
friend std::ostream& operator<<(std::ostream& out, const Matrix3D& matrix);
/**
* Overloading ">>" of a matrix.
* @param input
* @param matrix
* @return std::istream& input, used in the input.
*/
friend std::istream& operator>>(std::istream& input, Matrix3D& matrix);
/**
* Function to return a vector of the appropriate row requested.
* @param num, short number.
* @return Vector3D object which is the row requested.
*/
Vector3D row(short num);
/**
* Function to return a vector of the appropriate column requested.
* @param index, short number.
* @return Vector3D object which is the column requested.
*/
Vector3D column(short index);
/**
* Function to return the sum of the diagnoal numbers in the matrix.
* @return double, which is the requested sum.
*/
double trace();
/**
* Function to calculate the determinant of the matrix.
* @return double, which is the determinant of the matrix calculated.
*/
double determinant();
};
#endif //EX1_MATRIX3D_H