From: adam Date: Wed, 5 Dec 2007 07:31:41 +0000 (-0800) Subject: checkpoint X-Git-Url: http://git.megacz.com/?p=anneal.git;a=commitdiff_plain;h=43e3ce680ac8b6d621bb59c0eed326d87e728a61 checkpoint darcs-hash:20071205073141-5007d-8d4761d148f7496ba4992d17053ad62bfda77b30.gz --- diff --git a/src/edu/berkeley/qfat/Main.java b/src/edu/berkeley/qfat/Main.java index 9cbffcf..74f7098 100644 --- a/src/edu/berkeley/qfat/Main.java +++ b/src/edu/berkeley/qfat/Main.java @@ -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 es = new PriorityQueue(); @@ -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(); } diff --git a/src/edu/berkeley/qfat/Mesh.java b/src/edu/berkeley/qfat/Mesh.java index e66c814..b25d1b7 100644 --- a/src/edu/berkeley/qfat/Mesh.java +++ b/src/edu/berkeley/qfat/Mesh.java @@ -66,6 +66,24 @@ public class Mesh implements Iterable { } } + public void unscore() { + HashSet done = new HashSet(); + 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 done = new HashSet(); + 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 { 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 { 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; }