checkpoint
authoradam <adam@megacz.com>
Mon, 7 Jul 2008 19:18:33 +0000 (12:18 -0700)
committeradam <adam@megacz.com>
Mon, 7 Jul 2008 19:18:33 +0000 (12:18 -0700)
darcs-hash:20080707191833-5007d-c5defac839009eef0d5dddb4d5e410c26ecf5c0e.gz

src/edu/berkeley/qfat/bind/BindingGroup.java
src/edu/berkeley/qfat/bind/HasBindingGroup.java

index e93edf8..270bc78 100644 (file)
@@ -22,10 +22,11 @@ class BindingGroup<T extends HasBindingGroup> implements Iterable<T> {
     int size() { return matrices.size(); }
 
     /** merge another binding group with this one */
     int size() { return matrices.size(); }
 
     /** merge another binding group with this one */
-    void merge(BindingGroup<T> bg, Matrix m) {
+    void merge(BindingGroup<T> bg, Matrix m, float epsilon) {
         if (bg==this) {
         if (bg==this) {
-            if (m.equalsModuloEpsilon(Matrix.ONE, 0.001f)) return;
-            constraint = constraint.intersect(m.getAffineConstraint(0.001f), 0.001f);
+            if (m.equalsModuloEpsilon(Matrix.ONE, epsilon)) return;
+            // FIXME: what if points do not fall on the merged constraint-line?
+            constraint = constraint.intersect(m.getAffineConstraint(epsilon), epsilon);
             return;
         }
 
             return;
         }
 
@@ -36,15 +37,12 @@ class BindingGroup<T extends HasBindingGroup> implements Iterable<T> {
 
         // FIXME: what if points do not fall on the merged constraint-line?
         AffineConstraint ac = bg.constraint.multiply(getMatrix(master, bg.master));
 
         // FIXME: what if points do not fall on the merged constraint-line?
         AffineConstraint ac = bg.constraint.multiply(getMatrix(master, bg.master));
-        constraint = constraint.intersect(ac, 0.001f);
+        constraint = constraint.intersect(ac, epsilon);
 
 
-        HashSet<HasBindingGroup> stuff = new HashSet<HasBindingGroup>();
-        for(HasBindingGroup hbg : bg.matrices.keySet())
-            stuff.add(hbg);
-        bg.matrices.clear();
         bg.master = null;
         bg.master = null;
-        for(HasBindingGroup hbg : stuff)
+        for(HasBindingGroup hbg : bg.matrices.keySet())
             hbg.bindingGroupChanged();
             hbg.bindingGroupChanged();
+        bg.matrices.clear();
     }
 
     public Matrix getMatrix(T t) { return matrices.get(t); }
     }
 
     public Matrix getMatrix(T t) { return matrices.get(t); }
index ee8157a..1b19310 100644 (file)
@@ -14,6 +14,10 @@ public abstract class HasBindingGroup {
     // therefore: master = bindingGroup[self]^-1 * bindingMatrix * other
     // therefore:        = bindingGroup[self]^-1 * bindingMatrix * other.bindingGroup[other] * other.bindingGroup.master
     public void bindTo(Matrix bindingMatrix, HasBindingGroup other) {
     // therefore: master = bindingGroup[self]^-1 * bindingMatrix * other
     // therefore:        = bindingGroup[self]^-1 * bindingMatrix * other.bindingGroup[other] * other.bindingGroup.master
     public void bindTo(Matrix bindingMatrix, HasBindingGroup other) {
+        // FIXME
+        bindTo(bindingMatrix, other, 0.001f);
+    }
+    public void bindTo(Matrix bindingMatrix, HasBindingGroup other, float epsilon) {
         if (bindingGroup == null) bindingGroup = new BindingGroup(this);
         if (other.bindingGroup == null) other.bindingGroup = new BindingGroup(other);
 
         if (bindingGroup == null) bindingGroup = new BindingGroup(this);
         if (other.bindingGroup == null) other.bindingGroup = new BindingGroup(other);
 
@@ -21,7 +25,7 @@ public abstract class HasBindingGroup {
             getBindingMatrix().inverse()
             .times(bindingMatrix)
             .times(other.getBindingMatrix());
             getBindingMatrix().inverse()
             .times(bindingMatrix)
             .times(other.getBindingMatrix());
-        other.bindingGroup.merge(bindingGroup, bindingMatrix);
+        other.bindingGroup.merge(bindingGroup, bindingMatrix, epsilon);
     }
 
     public int bindingGroupSize() {
     }
 
     public int bindingGroupSize() {