checkpoint
authoradam <adam@megacz.com>
Tue, 18 Dec 2007 05:23:55 +0000 (21:23 -0800)
committeradam <adam@megacz.com>
Tue, 18 Dec 2007 05:23:55 +0000 (21:23 -0800)
darcs-hash:20071218052355-5007d-3e3bae9b3466cca98af2e44de859377b1906452d.gz

src/edu/berkeley/qfat/Main.java
src/edu/berkeley/qfat/Mesh.java
src/edu/berkeley/qfat/geom/BindingGroup.java
src/edu/berkeley/qfat/geom/HasBindingGroup.java
src/edu/berkeley/qfat/geom/Matrix.java

index 75bfd7e..641e440 100644 (file)
@@ -86,9 +86,10 @@ public class Main extends MeshViewer {
         float halfup = 0;
 
         translations = new Matrix[] {
         float halfup = 0;
 
         translations = new Matrix[] {
+
             Matrix.translate(new Vec(lshift,  depth,    halfup)),
             Matrix.translate(new Vec(lshift,  depth,    halfup)),
-            /*
             Matrix.translate(new Vec(rshift,  depth,    halfup)),
             Matrix.translate(new Vec(rshift,  depth,    halfup)),
+            /*
             Matrix.translate(new Vec(lshift, -depth,    halfup)),
             Matrix.translate(new Vec(rshift, -depth,    halfup)),
             */
             Matrix.translate(new Vec(lshift, -depth,    halfup)),
             Matrix.translate(new Vec(rshift, -depth,    halfup)),
             */
index 60aa9ab..b6ff386 100644 (file)
@@ -355,10 +355,15 @@ public class Mesh implements Iterable<Mesh.T> {
             return e.comparator() > comparator() ? 1 : -1;
         }
         public void bindEdge(E e, Matrix m) {
             return e.comparator() > comparator() ? 1 : -1;
         }
         public void bindEdge(E e, Matrix m) {
+            _bindEdge(e, m);
+            pair._bindEdge(e.pair, m);
+        }
+        public void _bindEdge(E e, Matrix m) {
             //bind_to.add(e);
 
             //bind_to.add(e);
 
-            //assumes edges are identical length at binding time
             e = e.pair;
             e = e.pair;
+            /*
+            //assumes edges are identical length at binding time
             Vec reflectionPlaneNormal = e.p2.p.minus(e.p1.p).norm();
             float a = reflectionPlaneNormal.x;
             float b = reflectionPlaneNormal.y;
             Vec reflectionPlaneNormal = e.p2.p.minus(e.p1.p).norm();
             float a = reflectionPlaneNormal.x;
             float b = reflectionPlaneNormal.y;
@@ -368,14 +373,13 @@ public class Mesh implements Iterable<Mesh.T> {
                             -2*a*b,  1-2*b*b,  -2*b*c, 0,
                             -2*a*c,   -2*b*c, 1-2*c*c, 0,
                             0,       0,       0,       1);
                             -2*a*b,  1-2*b*b,  -2*b*c, 0,
                             -2*a*c,   -2*b*c, 1-2*c*c, 0,
                             0,       0,       0,       1);
-            /*
             m = m.times(Matrix.translate(e.midpoint().minus(Point.ORIGIN))
                         .times(reflectionMatrix)
                         .times(Matrix.translate(Point.ORIGIN.minus(e.midpoint()))));
             m = m.times(Matrix.translate(e.midpoint().minus(Point.ORIGIN))
                         .times(reflectionMatrix)
                         .times(Matrix.translate(Point.ORIGIN.minus(e.midpoint()))));
-            */
             System.out.println(reflectionPlaneNormal);
             System.out.println("  " + p1.p + " " + m.times(e.p1.p));
             System.out.println("  " + p2.p + " " + m.times(e.p2.p));
             System.out.println(reflectionPlaneNormal);
             System.out.println("  " + p1.p + " " + m.times(e.p1.p));
             System.out.println("  " + p2.p + " " + m.times(e.p2.p));
+            */
             if (m.times(e.p1.p).minus(p1.p).mag() > EPSILON) throw new Error();
             if (m.times(e.p2.p).minus(p2.p).mag() > EPSILON) throw new Error();
             this.bindTo(m, e);
             if (m.times(e.p1.p).minus(p1.p).mag() > EPSILON) throw new Error();
             if (m.times(e.p2.p).minus(p2.p).mag() > EPSILON) throw new Error();
             this.bindTo(m, e);
index d1ff8b8..aec9329 100644 (file)
@@ -13,6 +13,7 @@ public class BindingGroup<T extends HasBindingGroup> implements Iterable<T> {
     }
 
     public void merge(BindingGroup<T> bg, Matrix m) {
     }
 
     public void merge(BindingGroup<T> bg, Matrix m) {
+        if (bg==this) throw new Error();
         for(HasBindingGroup hbg : bg.matrices.keySet()) {
             matrices.put((T)hbg, bg.matrices.get(hbg).times(m));
             hbg.bindingGroup = this;
         for(HasBindingGroup hbg : bg.matrices.keySet()) {
             matrices.put((T)hbg, bg.matrices.get(hbg).times(m));
             hbg.bindingGroup = this;
index fc12a29..5b761a3 100644 (file)
@@ -16,7 +16,8 @@ public abstract class HasBindingGroup {
         if (other.bindingGroup == null) other.bindingGroup = new BindingGroup(other);
 
         if (other.bindingGroup == this.bindingGroup) {
         if (other.bindingGroup == null) other.bindingGroup = new BindingGroup(other);
 
         if (other.bindingGroup == this.bindingGroup) {
-            if (getBindingMatrix(other).equals(bindingMatrix)) return;
+            if (getBindingMatrix(other).equals(bindingMatrix))
+                return;
             throw new Error("rebind attempt: "+this+" and "+other+" with "
                             + bindingMatrix
                             + "; expected "
             throw new Error("rebind attempt: "+this+" and "+other+" with "
                             + bindingMatrix
                             + "; expected "
@@ -24,7 +25,7 @@ public abstract class HasBindingGroup {
         }
 
         bindingMatrix =
         }
 
         bindingMatrix =
-            getBindingMatrix()
+            getBindingMatrix().inverse()
             .times(bindingMatrix)
             .times(other.getBindingMatrix());
         other.bindingGroup.merge(bindingGroup, bindingMatrix);
             .times(bindingMatrix)
             .times(other.getBindingMatrix());
         other.bindingGroup.merge(bindingGroup, bindingMatrix);
index 1c52d00..dbe4076 100644 (file)
@@ -256,7 +256,7 @@ public class Matrix {
             near(p,z.p);
     }
     private static final float EPSILON = 0.001f;
             near(p,z.p);
     }
     private static final float EPSILON = 0.001f;
-    private static boolean near(float a, float b) { return a==b; }
+    private static boolean near(float a, float b) { return Math.abs(a-b)<EPSILON; }
 
     public int hashCode() {
         return
 
     public int hashCode() {
         return