+ public void flip() {
+ // FIXME: coplanarity check needed
+ if (destroyed) return;
+ for (E e : (Iterable<E>)getBoundPeers()) {
+ if (!e.pair.isBoundTo(pair)) throw new RuntimeException("cannot flip!");
+ }
+ Vertex v1 = t.getOtherVertex(this);
+ Vertex v2 = pair.t.getOtherVertex(pair);
+ destroy();
+ pair.destroy();
+ T t1 = newT(v1, v2, this.v2);
+ T t2 = newT(v2, v1, this.v1);
+ t1.e1().sanity();
+ t1.e2().sanity();
+ t1.e3().sanity();
+ t2.e1().sanity();
+ t2.e2().sanity();
+ t2.e3().sanity();
+
+ for (E e : (Iterable<E>)getBoundPeers()) {
+ if (e==this) continue;
+ if (e.destroyed) continue;
+ Vertex v1e = e.t.getOtherVertex(e);
+ Vertex v2e = e.pair.t.getOtherVertex(e.pair);
+ e.destroy();
+ e.pair.destroy();
+ if (v1e.getE(v2e)!=null) throw new RuntimeException();
+ newT(v1e, v2e, e.v2).red = true;
+ newT(v2e, v1e, e.v1).red = true;
+ v2e.getE(v1e).bindTo(e.getBindingMatrix(this), v1.getE(v2));
+ v1e.getE(v2e).bindTo(e.pair.getBindingMatrix(this.pair), v2.getE(v1));
+ }
+
+ }