*/
class BindingGroup<T extends HasBindingGroup> implements Iterable<T> {
+ /** the arbitrarily-chosen master of the binding group */
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) {
matrices.put(master, Matrix.ONE);
}
+ /** the size of this binding group */
int size() { return matrices.size(); }
/** merge another binding group into this one */
/** 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);
}
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]"; }
+ };
}
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);
}
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;
}
}
// 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;
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); }
//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);
}
- System.out.println("done");
+ //System.out.println("done");
return null;
}