blob: 5ad4c8b461215f2230ddc08599b7017714823c17 (
plain)
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
|
#pragma once
#include <algorithm>
#include <array>
#include <cmath>
#include <exception>
#include <list>
#include <random>
#include <string>
#include <unordered_map>
#include <vector>
#include "array_hash.hpp"
class coordinate {
public:
double x;
double y;
coordinate operator+(const coordinate& r) const {
coordinate rp = {0, 0};
rp.x = x + r.x;
rp.y = y + r.y;
return rp;
}
template <class T>
coordinate operator*(const T& a) const {
coordinate rp = *this;
rp.x *= a;
rp.y *= a;
return rp;
}
coordinate operator-(const coordinate& r) const {
coordinate rp = *this;
return rp + (r * -1);
}
coordinate operator-() const {
return *this * -1;
}
void operator+=(const coordinate& r) {
x += r.x;
y += r.y;
}
};
class graph {
public:
typedef struct vertex {
coordinate r;
std::vector<unsigned> nd;
std::vector<unsigned> ne;
std::vector<coordinate> polygon;
} vertex;
typedef struct edge {
std::array<unsigned, 2> v;
coordinate r;
std::array<bool, 2> crossings;
} edge;
coordinate L;
std::vector<vertex> vertices;
std::vector<edge> edges;
std::vector<vertex> dual_vertices;
std::vector<edge> dual_edges;
graph(unsigned Nx, unsigned Ny);
graph(double Lx, double Ly, std::mt19937& rng);
graph(unsigned n, double a, std::mt19937& rng);
void helper(unsigned n, std::mt19937& rng);
graph const rotate();
std::string write() const;
coordinate Δr(unsigned e) const;
};
|