diff options
Diffstat (limited to 'spheres.cpp')
-rw-r--r-- | spheres.cpp | 36 |
1 files changed, 34 insertions, 2 deletions
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 <GL/glut.h> + +class animation : public measurement<double, 2, double> { + 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<double, 2, double>& m) override { + glClearColor(1.0f, 1.0f, 1.0f, 1.0f ); + glClear(GL_COLOR_BUFFER_BIT); + for (const Spin<double, 2, double>& 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<double, D, double> sphere(L, Z, B, std::floor(log2(L)), 2); + animation A(L, 750, argc, argv); + Model<double, D, double> 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<double, D> 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()); } |