checkpoint
authoradam <adam@megacz.com>
Sun, 16 Dec 2007 02:49:23 +0000 (18:49 -0800)
committeradam <adam@megacz.com>
Sun, 16 Dec 2007 02:49:23 +0000 (18:49 -0800)
darcs-hash:20071216024923-5007d-61ea66b3d3ac59ef7d3e99fd26c26997d868df9c.gz

src/edu/berkeley/qfat/Main.java

index 1a0239f..fb25e46 100644 (file)
@@ -26,19 +26,19 @@ import edu.berkeley.qfat.geom.Point;
 //    http://www.cs.cmu.edu/afs/cs/project/quake/public/code/predicates.c
 
 /*
 //    http://www.cs.cmu.edu/afs/cs/project/quake/public/code/predicates.c
 
 /*
-blender keys
-- middle mouse = option+click
-- right mouse = command+click
+  blender keys
+  - middle mouse = option+click
+  - right mouse = command+click
 
 
-3,7,1 = view along axes (control for opp direction)
-4, 8, 7, 2 = rotate in discrete increments (+control to translate)
-middle trag: rotate space
-shift+middle drag: translate space
-wheel: zoom
-home: home view: take current angle, zoom to whole scnee
-5 = ortho vs non-ortho
+  3,7,1 = view along axes (control for opp direction)
+  4, 8, 7, 2 = rotate in discrete increments (+control to translate)
+  middle trag: rotate space
+  shift+middle drag: translate space
+  wheel: zoom
+  home: home view: take current angle, zoom to whole scnee
+  5 = ortho vs non-ortho
 
 
- */
+*/
 
 
 // FIXME: re-orient goal (how?)
 
 
 // FIXME: re-orient goal (how?)
@@ -73,9 +73,9 @@ public class Main extends MeshViewer {
         float goal_depth  = goal.diagonal().dot(new Vec(0, 0, 1));
 
         /*
         float goal_depth  = goal.diagonal().dot(new Vec(0, 0, 1));
 
         /*
-        float width  = (float)0.6;
-        float height = (float)0.08;
-        float depth  = (float)0.3;
+          float width  = (float)0.6;
+          float height = (float)0.08;
+          float depth  = (float)0.3;
         */
         float width  = (float)0.7;
         float depth  = (float)0.08;
         */
         float width  = (float)0.7;
         float depth  = (float)0.08;
@@ -95,8 +95,8 @@ public class Main extends MeshViewer {
             Matrix.translate(new Vec(rshift, -depth,    halfup)),
 
             /*
             Matrix.translate(new Vec(rshift, -depth,    halfup)),
 
             /*
-            Matrix.translate(new Vec(0,  depth,    halfup)),
-            Matrix.translate(new Vec(0, -depth,    halfup)),
+              Matrix.translate(new Vec(0,  depth,    halfup)),
+              Matrix.translate(new Vec(0, -depth,    halfup)),
             */
 
             Matrix.translate(new Vec(lshift,       0,  height)),
             */
 
             Matrix.translate(new Vec(lshift,       0,  height)),
@@ -295,15 +295,15 @@ public class Main extends MeshViewer {
 
         Vec v;
         /*
 
         Vec v;
         /*
-        Matrix inv = p.errorQuadric();
-        v = new Vec(inv.d, inv.h, inv.l).norm().times(1/(float)300);
-        if (p.quadric_count == 0) {
-            v = goal.nearest(p.p).p.minus(p.p).norm().times(1/(float)300);
-        }
+          Matrix inv = p.errorQuadric();
+          v = new Vec(inv.d, inv.h, inv.l).norm().times(1/(float)300);
+          if (p.quadric_count == 0) {
+          v = goal.nearest(p.p).p.minus(p.p).norm().times(1/(float)300);
+          }
         */
         Vec v2 = new Vec((random.nextFloat() - (float)0.5) / 500,
         */
         Vec v2 = new Vec((random.nextFloat() - (float)0.5) / 500,
-                        (random.nextFloat() - (float)0.5)  / 500,
-                        (random.nextFloat() - (float)0.5)  / 500);
+                         (random.nextFloat() - (float)0.5)  / 500,
+                         (random.nextFloat() - (float)0.5)  / 500);
         //v = v.plus(v2.norm().times(1/(float)300));
         v = v2.norm().times(1/(float)300);
 
         //v = v.plus(v2.norm().times(1/(float)300));
         v = v2.norm().times(1/(float)300);
 
@@ -339,77 +339,75 @@ public class Main extends MeshViewer {
         float last = 10;
         while(true) {
             synchronized(this) {
         float last = 10;
         while(true) {
             synchronized(this) {
-            double ratio = (hits+misses==0) ? 1 : (hits / (hits+misses));
-            hits = 0;
-            misses = 0;
-            float gamma = 0;
-            double acceptance = ratio;
-            accepts = (int)(Math.ceil(ratio*100));
-            temps = (int)(Math.ceil(temp*1000));
-            vertss = tile.size();
-            if (breaks > 0) { while (breaks>0) {
-                breaks--;
-                    breakit();
-                    //gamma = 1;
-                    gamma = 1;
-                    //temp = last * 0.8f;
-                    //last = temp;
-                    //temp = hightemp;
-                } } else
-            if (acceptance > 0.96) gamma = 0.4f;
-            else if (acceptance > 0.9) gamma = 0.5f;
-            else if (acceptance > 0.8) gamma = 0.65f;
-            else if (acceptance > 0.6) gamma = 0.7f;
-            else {
-                if (acceptance > 0.3) {
-                    gamma = 0.9f;
-                } else if (acceptance > 0.15) {
-                    gamma = 0.95f;
-                } else if (acceptance > 0.10) {
-                    gamma = 0.98f;
-                } else {
-                    breakit();
-                    //gamma = 1;
-                    gamma = 0.99f;
-                    //gamma = 1;
-                    //temp = last * 0.8f;
-                    //last = temp;
-                    //temp = hightemp;
-                }
-            }
-            temp = temp * gamma;
+                double ratio = (hits+misses==0) ? 1 : (hits / (hits+misses));
+                hits = 0;
+                misses = 0;
+                float gamma = 0;
+                double acceptance = ratio;
+                accepts = (int)(Math.ceil(ratio*100));
+                temps = (int)(Math.ceil(temp*1000));
+                vertss = tile.size();
+                if (breaks > 0) { while (breaks>0) {
+                        breaks--;
+                        breakit();
+                        //gamma = 1;
+                        gamma = 1;
+                        //temp = last * 0.8f;
+                        //last = temp;
+                        //temp = hightemp;
+                    } } else
+                    if (acceptance > 0.96) gamma = 0.4f;
+                    else if (acceptance > 0.9) gamma = 0.5f;
+                    else if (acceptance > 0.8) gamma = 0.65f;
+                    else if (acceptance > 0.6) gamma = 0.7f;
+                    else {
+                        if (acceptance > 0.3) {
+                            gamma = 0.9f;
+                        } else if (acceptance > 0.15) {
+                            gamma = 0.95f;
+                        } else if (acceptance > 0.10) {
+                            gamma = 0.98f;
+                        } else {
+                            breakit();
+                            //gamma = 1;
+                            gamma = 0.99f;
+                            //gamma = 1;
+                            //temp = last * 0.8f;
+                            //last = temp;
+                            //temp = hightemp;
+                        }
+                    }
+                temp = temp * gamma;
 
 
 
 
-            HashSet<Mesh.Vertex> hs = new HashSet<Mesh.Vertex>();
-            for(Mesh.Vertex p : tile.vertices()) hs.add(p);
-            Mesh.Vertex[] pts = (Mesh.Vertex[])hs.toArray(new Mesh.Vertex[0]);
+                HashSet<Mesh.Vertex> hs = new HashSet<Mesh.Vertex>();
+                for(Mesh.Vertex p : tile.vertices()) hs.add(p);
+                Mesh.Vertex[] pts = (Mesh.Vertex[])hs.toArray(new Mesh.Vertex[0]);
 
 
-            int count = 0;
-            long then = System.currentTimeMillis();
-            for(int i=0; i<40; i++) {
-                if (anneal) {
-                    count++;
-                    Mesh.Vertex v = pts[Math.abs(random.nextInt()) % pts.length];
-                    rand(temp,v);
+                int count = 0;
+                long then = System.currentTimeMillis();
+                for(int i=0; i<40; i++) {
+                    if (anneal) {
+                        count++;
+                        Mesh.Vertex v = pts[Math.abs(random.nextInt()) % pts.length];
+                        rand(temp,v);
+                    }
+                    Thread.yield();
+                    repaint();
+                }
+                System.out.println("temp="+temp + " ratio="+(Math.ceil(ratio*100)) + " " +
+                                   "points_per_second=" +
+                                   (count*1000)/((double)(System.currentTimeMillis()-then)));
+
+                //for(Mesh.Vertex p : goal.vertices()) p.recomputeFundamentalQuadricIfNeighborChanged();
+                //for(Mesh.Vertex p : tile.vertices()) p.recomputeFundamentalQuadric();
+
+                synchronized(safeTriangles) {
+                    safeTriangles.clear();
+                    for(Mesh.T t : tile) if (t.shouldBeDrawn()) safeTriangles.add(t);
                 }
                 }
-                Thread.yield();
-                repaint();
-            }
-            System.out.println("temp="+temp + " ratio="+(Math.ceil(ratio*100)) + " " +
-                               "points_per_second=" +
-                               (count*1000)/((double)(System.currentTimeMillis()-then)));
-
-            for(Mesh.Vertex p : goal.vertices()) p.recomputeFundamentalQuadricIfNeighborChanged();
-            repaint();
-            for(Mesh.Vertex p : tile.vertices()) p.recomputeFundamentalQuadric();
-            repaint();
-
-            synchronized(safeTriangles) {
-                safeTriangles.clear();
-                for(Mesh.T t : tile) if (t.shouldBeDrawn()) safeTriangles.add(t);
-            }
             }
             }
-       }
+        }
     }
 
 
     }