checkpoint
authoradam <adam@megacz.com>
Mon, 7 Jul 2008 19:47:00 +0000 (12:47 -0700)
committeradam <adam@megacz.com>
Mon, 7 Jul 2008 19:47:00 +0000 (12:47 -0700)
darcs-hash:20080707194700-5007d-10a6e6f56e97b246550a43bccfac26e945ec8363.gz

src/edu/berkeley/qfat/bind/BindingGroup.java
src/edu/berkeley/qfat/bind/HasBindingGroup.java
src/edu/berkeley/qfat/geom/AffineConstraint.java
src/edu/berkeley/qfat/geom/Line.java
src/edu/berkeley/qfat/geom/Matrix.java
src/edu/berkeley/qfat/geom/Plane.java
src/edu/berkeley/qfat/geom/Point.java
src/edu/berkeley/qfat/geom/Polygon.java

index 9356ec4..00a7dd7 100644 (file)
@@ -10,8 +10,16 @@ import java.util.*;
  */
 class BindingGroup<T extends HasBindingGroup> implements Iterable<T> {
 
  */
 class BindingGroup<T extends HasBindingGroup> implements Iterable<T> {
 
+    /** the arbitrarily-chosen master of the binding group */
     private T                  master     = null;
     private T                  master     = null;
-    private AffineConstraint   constraint = new AffineConstraint.All();
+
+    /** the affine constraint, in master coordinates, of this binding group */
+    private AffineConstraint   constraint = AffineConstraint.ALL;
+
+    /**
+     *  For each member of the binding group, the matrix which must be
+     *  multiplied by the master to get the member's position
+     */
     private HashMap<T,Matrix>  matrices   = new HashMap<T,Matrix>();
 
     public BindingGroup(T master) {
     private HashMap<T,Matrix>  matrices   = new HashMap<T,Matrix>();
 
     public BindingGroup(T master) {
@@ -19,6 +27,7 @@ class BindingGroup<T extends HasBindingGroup> implements Iterable<T> {
         matrices.put(master, Matrix.ONE);
     }
 
         matrices.put(master, Matrix.ONE);
     }
 
+    /** the size of this binding group */
     int size() { return matrices.size(); }
 
     /** merge another binding group into this one */
     int size() { return matrices.size(); }
 
     /** merge another binding group into this one */
index b9b85b8..b7c8db3 100644 (file)
@@ -49,7 +49,7 @@ public abstract class HasBindingGroup {
 
     /** returns the AffineConstraint of this BG, translated into this HBG's space */
     public AffineConstraint getBindingConstraint() {
 
     /** returns the AffineConstraint of this BG, translated into this HBG's space */
     public AffineConstraint getBindingConstraint() {
-        if (bindingGroup==null) return new AffineConstraint.All();
+        if (bindingGroup==null) return AffineConstraint.ALL;
         return bindingGroup.getAffineConstraint(this);
     }
 
         return bindingGroup.getAffineConstraint(this);
     }
 
index 0ac6f03..0242f3a 100644 (file)
@@ -8,16 +8,18 @@ public interface AffineConstraint {
     public AffineConstraint intersect(AffineConstraint c, float epsilon);
     public AffineConstraint multiply(Matrix m);
 
     public AffineConstraint intersect(AffineConstraint c, float epsilon);
     public AffineConstraint multiply(Matrix m);
 
-    public static class All implements AffineConstraint {
-        public Point getProjection(Point p) { return p; }
-        public AffineConstraint intersect(AffineConstraint c, float epsilon) { return c; }
-        public AffineConstraint multiply(Matrix m) { return this; }
-    }
+    public static final AffineConstraint ALL = new AffineConstraint() {
+            public Point getProjection(Point p) { return p; }
+            public AffineConstraint intersect(AffineConstraint c, float epsilon) { return c; }
+            public AffineConstraint multiply(Matrix m) { return this; }
+            public String toString() { return "[AffineConstraint: ALL]"; }
+        };
 
 
-    public static class Nothing implements AffineConstraint {
-        public Point getProjection(Point p) { return null; }
-        public AffineConstraint intersect(AffineConstraint c, float epsilon) { return this; }
-        public AffineConstraint multiply(Matrix m) { return this; }
-    }
+    public static final AffineConstraint NONE = new AffineConstraint() {
+            public Point getProjection(Point p) { return null; }
+            public AffineConstraint intersect(AffineConstraint c, float epsilon) { return this; }
+            public AffineConstraint multiply(Matrix m) { return this; }
+            public String toString() { return "[AffineConstraint: NONE]"; }
+        };
 
 }
 
 }
index cafa081..14a1f6d 100644 (file)
@@ -67,8 +67,8 @@ public class Line implements AffineConstraint {
             Math.abs(this.d-line.d) <= epsilon)
             return this;
         float x = (line.c-this.c)/(this.m-line.m);
             Math.abs(this.d-line.d) <= epsilon)
             return this;
         float x = (line.c-this.c)/(this.m-line.m);
-        if (Math.abs( (m*x+c)-(line.m*x+line.c) ) > epsilon ) return null;
-        if (Math.abs( (n*x+d)-(line.n*x+line.d) ) > epsilon ) return null;
+        if (Math.abs( (m*x+c)-(line.m*x+line.c) ) > epsilon ) return AffineConstraint.NONE;
+        if (Math.abs( (n*x+d)-(line.n*x+line.d) ) > epsilon ) return AffineConstraint.NONE;
         return new Point(x, m*x+c, n*x+d);
     }
 
         return new Point(x, m*x+c, n*x+d);
     }
 
index c2419d6..33417da 100644 (file)
@@ -382,7 +382,7 @@ public class Matrix {
         c = Math.abs(c) <= epsilon ? 0 : c;
         d = Math.abs(d) <= epsilon ? 0 : d;
         if (a!=0 || b!=0 || c!=0) return new Plane(a, b, c, d);
         c = Math.abs(c) <= epsilon ? 0 : c;
         d = Math.abs(d) <= epsilon ? 0 : d;
         if (a!=0 || b!=0 || c!=0) return new Plane(a, b, c, d);
-        if (d==0) return new AffineConstraint.All();
-        return new AffineConstraint.Nothing();
+        if (d==0) return AffineConstraint.ALL;
+        return AffineConstraint.NONE;
     }
 }
     }
 }
index 36f18a3..ed721ed 100644 (file)
@@ -52,7 +52,7 @@ public class Plane implements AffineConstraint {
 
             // parallel planes
             if (Math.abs(p.norm().cross(norm()).mag()) <= epsilon)
 
             // parallel planes
             if (Math.abs(p.norm().cross(norm()).mag()) <= epsilon)
-                return new AffineConstraint.Nothing();
+                return AffineConstraint.NONE;
 
             Vec u = norm().cross(p.norm());
             Point point = null;
 
             Vec u = norm().cross(p.norm());
             Point point = null;
index b98fb2d..d53a2e8 100644 (file)
@@ -37,8 +37,7 @@ public final class Point implements HasBoundingBox, AffineConstraint, HasPoint {
     public Point getProjection(Point p) { return this; }
     public AffineConstraint intersect(AffineConstraint c, float epsilon) {
         if (c.getProjection(this).distance(this) <= epsilon) return this;
     public Point getProjection(Point p) { return this; }
     public AffineConstraint intersect(AffineConstraint c, float epsilon) {
         if (c.getProjection(this).distance(this) <= epsilon) return this;
-        System.err.println("off by: " + c.getProjection(this).distance(this));
-        return new AffineConstraint.Nothing();
+        return AffineConstraint.NONE;
     }
     public AffineConstraint multiply(Matrix m) { return m.times(this); }
 
     }
     public AffineConstraint multiply(Matrix m) { return m.times(this); }
 
index 00458b2..b69c3d7 100644 (file)
@@ -65,10 +65,10 @@ public final class Polygon {
         //centroid = new Point(round(centroid.x), round(centroid.y), round(centroid.z));
         if (segments.size() >= 3)
         for(Segment s : segments) {
         //centroid = new Point(round(centroid.x), round(centroid.y), round(centroid.z));
         if (segments.size() >= 3)
         for(Segment s : segments) {
-            System.out.println("newt! " + s.p1 + " " + centroid + " " + s.p2 + " " + plane.norm().times(-1));
+            //System.out.println("newt! " + s.p1 + " " + centroid + " " + s.p2 + " " + plane.norm().times(-1));
             mesh.newT(s.p1, centroid, s.p2, plane.norm().times(-1), 0);
         }
             mesh.newT(s.p1, centroid, s.p2, plane.norm().times(-1), 0);
         }
-        System.out.println("done");
+        //System.out.println("done");
         return null;
     }
 
         return null;
     }