checkpoint
[anneal.git] / src / edu / berkeley / qfat / Mesh.java
index e3a7cde..1d4967f 100644 (file)
@@ -15,7 +15,7 @@ public class Mesh implements Iterable<Mesh.T> {
     public static final Random random = new Random();
 
     private PointSet<Vert> pointset = new PointSet<Vert>();
-
+    public int size() { return pointset.size(); }
     public Iterable<Vert> vertices() { return pointset; }
 
     public Iterable<E> edges() {
@@ -239,15 +239,15 @@ public class Mesh implements Iterable<Mesh.T> {
                 else if (nearest_in_other_mesh == null) {
                     if (score_against != null) {
                         Vert ne = score_against.nearest(p);
-                        oldscore = ne.fundamentalQuadric().preAndPostMultiply(p) * 100 * 100;
+                        oldscore = ne.fundamentalQuadric().preAndPostMultiply(p) * 100 * 10;
                     } else {
                         oldscore = 0;
                     }
                 } else {
-                    oldscore = nearest_in_other_mesh.fundamentalQuadric().preAndPostMultiply(p) * 100 * 100;
+                    oldscore = nearest_in_other_mesh.fundamentalQuadric().preAndPostMultiply(p) * 100 * 10;
                 }
             } else {
-                oldscore = (quadric.preAndPostMultiply(p) * 100);
+                oldscore = (quadric.preAndPostMultiply(p) * 100) / quadric_count;
             }
 
             oldscore = oldscore;
@@ -266,7 +266,7 @@ public class Mesh implements Iterable<Mesh.T> {
                 }
                 */
 
-                float minangle = (float)(Math.PI * 0.9);
+                float minangle = (float)(Math.PI * 0.8);
                 if (ang > minangle)
                     oldscore += (ang - minangle);
 
@@ -295,16 +295,25 @@ public class Mesh implements Iterable<Mesh.T> {
             }
             applyQuadricToNeighbor();
 
+            // FIXME: intersection test needed?
+            boolean good = true;
+
             // should recompute fundamental quadrics of all vertices sharing a face, but we defer...
             E e = this.e;
             do {
+                /*
+                if (Math.abs(e.crossAngle()) > (Math.PI * 0.9) ||
+                    Math.abs(e.next.crossAngle()) > (Math.PI * 0.9)) {
+                    good = false;
+                }
+                if (e.t.aspect() < 0.1) {
+                    good = false;
+                }
+                */
                 e.p2.quadricStale = true;
                 e = e.pair.next;
             } while(e != this.e);
 
-            // FIXME: intersection test needed?
-            boolean good = true;
-
             if (!ignorecollision)
             for(T t : Mesh.this) {
                 if (!good) break;
@@ -471,7 +480,8 @@ public class Mesh implements Iterable<Mesh.T> {
                 return (float)(length()*Math.sqrt(t.area()));
             return length()*t.area();
             */
-            return length() + midpoint().distance(nearest.p);
+            return (float)Math.max(length(), midpoint().distance(nearest.p));
+            //return length();
         }
         public int compareTo(E e) {
             return e.comparator() > comparator() ? 1 : -1;