summaryrefslogtreecommitdiff
path: root/spheres_infinite.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'spheres_infinite.cpp')
-rw-r--r--spheres_infinite.cpp84
1 files changed, 72 insertions, 12 deletions
diff --git a/spheres_infinite.cpp b/spheres_infinite.cpp
index 5287a84..e41ea17 100644
--- a/spheres_infinite.cpp
+++ b/spheres_infinite.cpp
@@ -14,9 +14,11 @@ private:
uint64_t t2;
unsigned n;
unsigned tmp;
+ unsigned wait;
+ Euclidean<double, D> s0_tmp;
public:
- animation(double L, unsigned w, int argc, char* argv[]) {
+ animation(double L, unsigned w, int argc, char* argv[]) : s0_tmp(0), wait(1000) {
t1 = 0;
t2 = 0;
n = 0;
@@ -24,37 +26,65 @@ public:
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(w, w);
- glutCreateWindow("wolff");
+ glutCreateWindow("wolffWindow");
glClearColor(0.0, 0.0, 0.0, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-L, L, -L, L);
}
- void pre_cluster(const model&, unsigned, const Euclidean<double, D>&) override { tmp = 0; }
-
- void plain_site_transformed(const model&, const Spin<double, D, double>*,
- const Spin<double, D, double>&) override {
+ void plain_site_transformed(const model& m, const Transformation<double, D, Euclidean<double, D>, double>& t) override {
+ if (n > wait) {
+ if (t.current().size() > 1) {
+ glColor3f(0.0f, 0.0f, 1.0f);
+ } else {
+ glColor3f(0.0f, 1.0f, 0.0f);
+ }
+ for (const Spin<double, 2, double>* s : t.current()) {
+ if (s != NULL) {
+ glBegin(GL_POLYGON);
+ unsigned n_points = 50;
+ for (unsigned i = 0; i < n_points; i++) {
+ glVertex2d(s0_tmp.act(*s).x(0) + s->s * cos(2 * i * M_PI / n_points),
+ s0_tmp.act(*s).x(1) + s->s * sin(2 * i * M_PI / n_points));
+ }
+ glEnd();
+ }
+ }
+ }
tmp++;
}
- void post_cluster(const model& m) override {
+ void pre_cluster(const model& m, unsigned, const Transformation<double, D, Euclidean<double, D>, double>* t) override {
+ s0_tmp = m.s0.inverse();
+ tmp = 0;
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
+ /*
+ glBegin(GL_LINE);
+ Vector<double, 2> r_center = s0_tmp.act({t->r.t, 0});
+ glEnd();
+ */
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));
+ glVertex2d(s0_tmp.act(*s).x(0) + s->s * cos(2 * i * M_PI / n_points),
+ s0_tmp.act(*s).x(1) + s->s * sin(2 * i * M_PI / n_points));
}
glEnd();
}
glFlush();
+ }
+ void post_cluster(const model& m) override {
+ glFlush();
t1 += tmp;
t2 += tmp * tmp;
+ if (n > wait) {
+ sleep(2);
+ }
n++;
}
@@ -105,18 +135,47 @@ Gen<double, D, Euclidean<double, D>, double> mGen(double ε) {
Vector<double, D> t12 = t1 - t2;
Vector<double, D> t = (t1 + t2) / 2;
- double θ = atan2(t12[1], t12[0]) + rng.variate<double, std::normal_distribution>(0.0, ε);
+ double θ = atan2(t12(1), t12(0)) + rng.variate<double, std::normal_distribution>(0.0, ε) / t12.norm();
m(0, 0) = -cos(2 * θ);
m(1, 1) = cos(2 * θ);
m(0, 1) = -2 * cos(θ) * sin(θ);
m(1, 0) = -2 * cos(θ) * sin(θ);
- Euclidean<double, D> g(t - m * t, m);
+ Vector<double, D> t3 = t - m * t;
+
+ if (t3(0) != t3(0)) {
+ std::cout << t3 << "\n" << t << "\n" << m << "\n" << t12 << "\n" ;
+ getchar();
+ }
+
+ Euclidean<double, D> g(t3, m);
return new PairFlip<double, D, Euclidean<double, D>, double>(M, g, s1, s2);
};
}
+Gen<double, D, Euclidean<double, D>, double> rGen(double ε) {
+ return [ε](model& M, Rng& rng) -> Transformation<double, D, Euclidean<double, D>, double>* {
+ Vector<double, D> t;
+ Matrix<double, D> m;
+
+ double θ = rng.uniform((double)0.0, 2 * M_PI);
+ m(0, 0) = -cos(2 * θ);
+ m(1, 1) = cos(2 * θ);
+ m(0, 1) = -2 * cos(θ) * sin(θ);
+ m(1, 0) = -2 * cos(θ) * sin(θ);
+
+ Spin<double, D, double>* s = rng.pick(M.s);
+ t = M.s0.t;
+ for (unsigned j = 0; j < D; j++) {
+ t(j) += rng.variate<double, std::normal_distribution>(0.0, ε);
+ }
+
+ Euclidean<double, D> g(t - m * t, m);
+ return new SpinFlip<double, D, Euclidean<double, D>, double>(M, g, s);
+ };
+}
+
int main(int argc, char* argv[]) {
const unsigned D = 2;
@@ -180,7 +239,8 @@ int main(int argc, char* argv[]) {
};
auto g1 = eGen(1);
- auto g2 = mGen(0.5);
+ auto g2 = mGen(0.1);
+ auto g3 = rGen(1);
animation A(L, 750, argc, argv);
model sphere(1.0, Z, B);