From 6590ea62a85d482b1da79fbfc4b46af52ed30c75 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Mon, 2 Dec 2019 21:14:11 -0500 Subject: animation and mesuerements --- spheres.cpp | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'spheres.cpp') diff --git a/spheres.cpp b/spheres.cpp index 633a26a..25c5a67 100644 --- a/spheres.cpp +++ b/spheres.cpp @@ -1,5 +1,36 @@ #include "space_wolff.hpp" +#include + +class animation : public measurement { + public: + animation(double L, unsigned w, int argc, char *argv[]) { + glutInit(&argc, argv); + glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); + glutInitWindowSize(w, w); + glutCreateWindow("wolff"); + glClearColor(0.0,0.0,0.0,0.0); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluOrtho2D(-1, L + 1, -1 , L + 1); + } + + void post_cluster(const Model& m) override { + glClearColor(1.0f, 1.0f, 1.0f, 1.0f ); + glClear(GL_COLOR_BUFFER_BIT); + for (const Spin& s : m.s) { + glBegin(GL_POLYGON); + unsigned n_points = 50; + glColor3f(0.0f, 0.0f, 0.0f); + for (unsigned i = 0; i < n_points; i++) { + glVertex2d(m.s0.inverse().act(s).x(0) + s.s * cos(2 * i * M_PI / n_points), m.s0.inverse().act(s).x(1) + s.s * sin(2 * i * M_PI / n_points)); + } + glEnd(); + } + glFlush(); + getchar(); + } +}; int main(int argc, char* argv[]) { const unsigned D = 2; @@ -54,7 +85,8 @@ int main(int argc, char* argv[]) { return H * sin(2 * M_PI * 3 * s.x(0) / L); }; - Model sphere(L, Z, B, std::floor(log2(L)), 2); + animation A(L, 750, argc, argv); + Model sphere(L, Z, B, std::floor(log2(L)), 2, A); randutils::auto_seed_128 seeds; std::mt19937 rng{seeds}; @@ -65,7 +97,7 @@ int main(int argc, char* argv[]) { for (unsigned i = 0; i < n; i++) { Vector pos = {dist(rng), dist(rng)}; - sphere.s.push_back({pos, 0.5}); + sphere.s.push_back({pos, dist(rng) / L}); sphere.dict.insert(&sphere.s.back()); } -- cgit v1.2.3-54-g00ecf