import javax.media.opengl.*;
import java.util.*;
-/** tracks an equivalence class of geometric objects which are related to each other by transformation matrices */
-public class BindingGroup<T extends HasBindingGroup> implements Iterable<T> {
+/**
+ * An equivalence class of geometric objects whose positions are
+ * related by affine transformation matrices and are constrained by
+ * an affine constraint.
+ */
+class BindingGroup<T extends HasBindingGroup> implements Iterable<T> {
private T master = null;
private AffineConstraint constraint = new AffineConstraint.All();
matrices.put(master, Matrix.ONE);
}
- public int size() { return matrices.size(); }
+ int size() { return matrices.size(); }
- public void merge(BindingGroup<T> bg, Matrix m) {
+ /** merge another binding group with this one */
+ void merge(BindingGroup<T> bg, Matrix m, float epsilon) {
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;
}
// 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>();
+ bg.master = null;
for(HasBindingGroup hbg : bg.matrices.keySet())
- stuff.add(hbg);
+ hbg.bindingGroupChanged();
bg.matrices.clear();
- bg.master = null;
- for(HasBindingGroup hbg : stuff)
- hbg.bindingGroupChanged(this);
}
public Matrix getMatrix(T t) { return matrices.get(t); }