-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.hpp
More file actions
60 lines (49 loc) · 1.04 KB
/
util.hpp
File metadata and controls
60 lines (49 loc) · 1.04 KB
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
#ifndef POLYLOWER_UTIL_H
#define POLYLOWER_UTIL_H
#include "vec.hpp"
#include <vector>
#include <array>
using std::vector;
using std::array;
struct Mat4 {
double *m;
Mat4() : m(new double[16]) {
for (int i = 0; i < 16; i++)
m[i] = 0.0;
}
Mat4(const Mat4 &M) {
for (int i = 0; i < 16; i++)
m[i] = M.m[i];
}
Mat4(Mat4 &&M) : m(M.m) {
M.m = nullptr;
}
Mat4& operator=(const Mat4 &rhs) {
for (int i = 0; i < 16; i++)
m[i] = rhs.m[i];
return *this;
}
Mat4& operator=(Mat4 &&rhs) {
if (this != &rhs) {
delete [] m;
m = rhs.m;
rhs.m = nullptr;
}
return *this;
}
Mat4 operator+(const Mat4 &rhs) const {
Mat4 n;
for (int i = 0; i < 16; i++) {
n.m[i] = m[i] + rhs.m[i];
}
return n;
}
Mat4& operator+=(const Mat4 &rhs) {
for (int i = 0; i < 16; i++)
m[i] += rhs.m[i];
return *this;
}
int solve(vec &ans);
};
void triangularize(const vector<vec> &vertices, const vector<vector<int>> &faces, vector<array<int, 3>> &tfaces);
#endif