- public Vec norm() {
- Vec norm = new Vec(0, 0, 0);
- E e = this.e;
- do {
- if (e.t != null) norm = norm.plus(e.t.norm().times((float)e.prev.angle()));
- e = e.pair.next;
- } while(e != this.e);
- return norm.norm();
+ }
+
+ public class BindingGroup {
+ private HashSet<E> set = new HashSet<E>();
+ public BindingGroup bind_others;
+ public BindingGroup other() { return bind_others; }
+ public BindingGroup(BindingGroup bind_others) { this.bind_others = bind_others; }
+ public BindingGroup() { this.bind_others = new BindingGroup(this); }
+ public BindingGroup(E e) { this(); set.add(e); }
+ public void add(E e) {
+ if (set.contains(e)) return;
+ set.add(e);
+ BindingGroup e_bind_peers = e.bind_peers;
+ BindingGroup e_bind_to = e.bind_to;
+ e.bind_peers = this;
+ e.bind_to = bind_others;
+ for (E epeer : e_bind_peers.set) add(epeer);
+ for (E eother : e_bind_to.set) bind_others.add(eother);
+
+ for(E eother : bind_others.set) {
+ if (e.next.bind_to.set.contains(eother.prev)) {
+ e.next.next.bindEdge(eother.prev.prev);
+ }
+ if (e.prev.bind_to.set.contains(eother.next)) {
+ e.prev.prev.bindEdge(eother.next.next);
+ }
+ }
+
+ }
+ public void dobind(E e) {
+ for(E ebound : set) {
+ e.p1.bind(ebound.p2);
+ e.p2.bind(ebound.p1);
+ }
+ }
+ public void shatter(BindingGroup bg1, BindingGroup bg2) {
+ for(E e : set) {
+ e.shatter(e.midpoint(), bg1, bg2);
+ }