-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmat3.cpp
More file actions
64 lines (56 loc) · 967 Bytes
/
mat3.cpp
File metadata and controls
64 lines (56 loc) · 967 Bytes
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
#include "mat3.hpp"
Mat3::Mat3()
{
for(int i=0; i<9; i++)
{
this->vals[i] = 0.0;
}
}
Mat3::Mat3(const Mat3& mat)
{
for(int i=0; i<9; i++)
{
this->vals[i] = mat.vals[i];
}
}
Mat3::Mat3(double* values)
{
for(int i=0; i<9; i++)
{
this->vals[i] = values[i];
}
}
Mat3& Mat3::operator=(const Mat3& mat)
{
for(int i=0; i<9; i++)
{
this->vals[i] = mat.vals[i];
}
return *this;
}
Mat3 Mat3::operator+(const Mat3& mat) const
{
Mat3 sum;
for(int i=0; i<9; i++)
{
sum.vals[i] = this->vals[i] + mat.vals[i];
}
return sum;
}
Mat3 Mat3::operator-(const Mat3& mat) const
{
Mat3 diff;
for(int i=0; i<9; i++)
{
diff.vals[i] = this->vals[i] - mat.vals[i];
}
return diff;
}
double Mat3::get(int row, int col) const
{
return this->vals[row*3 + col];
}
void Mat3::set(int row, int col, double val)
{
this->vals[row*3 + col] = val;
}