package edu.berkeley.qfat.bind;
import edu.berkeley.qfat.geom.*;
-import javax.media.opengl.*;
import java.util.*;
/**
*/
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) {
+ BindingGroup(T master) {
this.master = master;
matrices.put(master, Matrix.ONE);
}
+ /** the size of this binding group */
int size() { return matrices.size(); }
/** merge another binding group into this one */
void merge(BindingGroup<T> bg, Matrix m, float epsilon) {
if (bg==this) {
if (m.equalsModuloEpsilon(Matrix.ONE, epsilon)) return;
+ /*
+ if (master instanceof edu.berkeley.qfat.Mesh.Vertex)
+ System.err.println(m.times(m));
+ */
// FIXME: what if points do not fall on the merged constraint-line?
constraint = constraint.intersect(m.getAffineConstraint(epsilon), epsilon);
return;
}
+ // bg.master = m * master
+ // hbg = bg.getMatrix(hbg) * bg.master
+ // hbg = bg.getMatrix(hbg) * m * master
for(HasBindingGroup hbg : bg) {
matrices.put((T)hbg, bg.getMatrix((T)hbg).times(m));
hbg.bindingGroup = this;
bg.matrices = null;
}
- public Matrix getMatrix(T t) { return matrices.get(t); }
+ Matrix getMatrix(T t) { return matrices.get(t); }
public Iterator<T> iterator() { return matrices.keySet().iterator(); }
/** t1 = getMatrix(t1, t2) * t2 */
- public Matrix getMatrix(T t1, T t2) {
+ Matrix getMatrix(T t1, T t2) {
// t1 = getMatrix(t1) * master
// getMatrix(t2)^-1 * t2 = master
// t1 = getMatrix(t1) * getMatrix(t2)^-1 * t2
return getMatrix(t1).times(getMatrix(t2).inverse());
}
- public AffineConstraint getAffineConstraint(T t) {
+ AffineConstraint getAffineConstraint(T t) {
return constraint.multiply(matrices.get(t));
}
matrices = newmatrices;
}
- public boolean contains(HasBindingGroup t) {
+ boolean contains(HasBindingGroup t) {
return matrices.get((T)t) != null;
}
}