checkpoint
authoradam <adam@megacz.com>
Wed, 5 Dec 2007 07:31:41 +0000 (23:31 -0800)
committeradam <adam@megacz.com>
Wed, 5 Dec 2007 07:31:41 +0000 (23:31 -0800)
darcs-hash:20071205073141-5007d-8d4761d148f7496ba4992d17053ad62bfda77b30.gz

src/edu/berkeley/qfat/Main.java
src/edu/berkeley/qfat/Mesh.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();
             }
index e66c814..b25d1b7 100644 (file)
@@ -66,6 +66,24 @@ public class Mesh implements Iterable<Mesh.T> {
         }
     }
 
+    public void unscore() {
+        HashSet<Vert> done = new HashSet<Vert>();
+        for(T t : this)
+            for(Vert p : new Vert[] { t.v1(), t.v2(), t.v3() }) {
+                if (done.contains(p)) continue;
+                done.add(p);
+                p.unscore();
+            }
+    }
+    public void fundamental() {
+        HashSet<Vert> done = new HashSet<Vert>();
+        for(T t : this)
+            for(Vert p : new Vert[] { t.v1(), t.v2(), t.v3() }) {
+                if (done.contains(p)) continue;
+                done.add(p);
+                p.recomputeFundamentalQuadric();
+            }
+    }
     public float rescore() {
         int num = 0;
         double dist = 0;
@@ -74,8 +92,8 @@ public class Mesh implements Iterable<Mesh.T> {
             for(Vert p : new Vert[] { t.v1(), t.v2(), t.v3() }) {
                 if (done.contains(p)) continue;
                 done.add(p);
-                //p.rescore();
-                p.recomputeFundamentalQuadric();
+                p.rescore();
+                
             }
         return (float)(dist/num);
     }
@@ -204,7 +222,7 @@ public class Mesh implements Iterable<Mesh.T> {
             s2 = quadric==null ? 0 : po.p.distance(quadric.p);
             oldscore = (float)(s1 + s2);
             */
-            oldscore = quadric.preAndPostMultiply(p);
+            oldscore = quadric_count == 0 ? 0 : (quadric.preAndPostMultiply(p) / quadric_count);
 
             score += oldscore;
         }