-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMatrix4.cpp
52 lines (45 loc) · 1.14 KB
/
Matrix4.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
#include "Matrix4.h"
#include <iostream>
#include <iomanip>
using namespace std;
Matrix4::Matrix4()
{
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{
this->val[i][j] = 0;
}
}
}
Matrix4::Matrix4(double val[4][4])
{
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{
this->val[i][j] = val[i][j];
}
}
}
Matrix4::Matrix4(const Matrix4 &other)
{
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{
this->val[i][j] = other.val[i][j];
}
}
}
ostream &operator<<(ostream &os, const Matrix4 &m)
{
os << fixed << setprecision(6) << "|" << m.val[0][0] << "|" << m.val[0][1] << "|" << m.val[0][2] << "|" << m.val[0][3] << "|"
<< endl
<< "|" << m.val[1][0] << "|" << m.val[1][1] << "|" << m.val[1][2] << "|" << m.val[1][3] << "|"
<< endl
<< "|" << m.val[2][0] << "|" << m.val[2][1] << "|" << m.val[2][2] << "|" << m.val[2][3] << "|"
<< endl
<< "|" << m.val[3][0] << "|" << m.val[3][1] << "|" << m.val[3][2] << "|" << m.val[3][3] << "|";
return os;
}