#pragma once #include #include #include #include #include #include #include #include #include #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 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 nd; std::vector ne; std::vector polygon; } vertex; typedef struct edge { std::array v; coordinate r; std::array crossings; } edge; coordinate L; std::vector vertices; std::vector edges; std::vector dual_vertices; std::vector 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; };