checkpoint
[anneal.git] / src / edu / berkeley / qfat / Main.java
index 9cbffcf..74f7098 100644 (file)
@@ -239,7 +239,7 @@ public class Main implements GLEventListener, MouseListener, MouseMotionListener
         Random random = new Random();
 
     public synchronized void breakit() {
-        if (verts > 200) return;
+        if (verts > 400) return;
         //double min = (tile.avgedge/tile.numedges)*(1+(4/(double)verts));
         //if (verts>0 && tile.es.peek().length() < min) return;
         PriorityQueue<Mesh.E> es = new PriorityQueue<Mesh.E>();
@@ -272,14 +272,14 @@ public class Main implements GLEventListener, MouseListener, MouseMotionListener
         Vec v = p.nearest_vert_in_other_mesh().minus(p.p).norm().times(r1);
         */
         //v = p.norm().times(v.dot(p.norm()));
-        /*
+
         Vec v = new Vec((random.nextFloat() - (float)0.5) / 1000,
                         (random.nextFloat() - (float)0.5) / 1000,
                         (random.nextFloat() - (float)0.5) / 1000);
-        */
+        /*
         Matrix inv = p.errorQuadric();
         Vec v = new Vec(inv.d, inv.h, inv.l).norm().times(1/(float)1000);
-
+        */
         boolean aspect = false;//(Math.abs(random.nextInt()) % 100) <= 2;
         Matrix old_tile_aspect = null;//goal.aspect;
         boolean good = true;
@@ -297,16 +297,17 @@ public class Main implements GLEventListener, MouseListener, MouseMotionListener
         double new_tile_score = tile.score();
         double new_goal_score = goal.score();
         double tile_delta = new_tile_score - tile_score;
-        double goal_delta = new_goal_score - goal_score;
+        double goal_delta = 0;//new_goal_score - goal_score;
         double delta = tile_delta + goal_delta;
         double swapProbability = Math.exp((-1 * delta) / temperature);
         //boolean doSwap = Math.random() < swapProbability;
         boolean doSwap = good && (tile_delta <= 0 && goal_delta <= 0);
+        //boolean doSwap = true;
         //System.out.println(doSwap);
         if (doSwap) {
             tile_score = new_tile_score;
             goal_score = new_goal_score;
-            //System.out.println("score: " + tile_score + " / " + goal_score);
+            System.out.println("score: " + tile_score + " / " + goal_score);
             if (aspect) System.out.println("aspect " + v);
         } else {
             if (aspect) {
@@ -466,6 +467,10 @@ public class Main implements GLEventListener, MouseListener, MouseMotionListener
                     for(Mesh.Vert p : new Mesh.Vert[] { t.v1(), t.v2(), t.v3() }) {
                         rand(10,p);
                     }
+                goal.unscore();
+                tile.unscore();
+                goal.fundamental();
+                tile.fundamental();
                 goal.rescore();
                 tile.rescore();
             }