e.flip();
System.out.println("flip!");
i++;
- //if (i>2) break;
}
System.out.println("count="+count);
- /*
- tris.clear();
- for (T t : this) if (t.v1().edge && t.v2().edge && t.v3().edge) tris.add(t);
- for (T t : tris)
- t.shatter();
- */
-
- /*
- for(Vertex v : verts) {
- if (!v.face) continue;
- v.move(v.recenter().minus(v.getPoint()), false);
- }
- */
- /*
- Queue<T> q = new LinkedList<T>();
- OUTER: while(true) {
- for (T t : this) {
- if (t.old) { t.shatter(); continue OUTER; }
- }
- break;
- }
- */
-
rebindPoints();
HashSet<Vertex> verts = new HashSet<Vertex>();
for(Vertex v : vertices()) verts.add(v);
}
for (Vertex v : verts)
v.grantWish();
-
+ System.out.println("-------------------------------------------------------------------");
+ /*
+ for (Vertex v : verts) {
+ if (v.original) {
+ int n=0;
+ for(E e = v.e; e!=null; e=e.pair.next==v.e?null:e.pair.next) {
+ n++;
+ v.wish(e.midpoint());
+ v.wish(e.midpoint());
+ v.wish(e.next.pair.t.centroid());
+ }
+ v.avgWish();
+ v.wishes = 3;
+ for(int j=0; j<n-3; j++)
+ v.wish(v.getPoint());
+ }
+ }
+ for (Vertex v : verts)
+ v.avgWish();
+ for (Vertex v : verts)
+ v.grantWish();
+ */
}
// Vertexices //////////////////////////////////////////////////////////////////////////////
public void grantWish() {
for(Vertex v : (Iterable<Vertex>)getBoundPeers()) {
if (v==this) continue;
+ if (v.wishes==0) continue;
Point p = this.getBindingMatrix(v).times(v.wish.minus(Point.ZERO).div(v.wishes).plus(Point.ZERO));
wish = p.minus(Point.ZERO).times(v.wishes).plus(wish);
wishes += v.wishes;
move(d, false);
clearWish();
}
+ public void avgWish() {
+ if (wishes==0) return;
+ wish = wish.minus(Point.ZERO).div(wishes).plus(Point.ZERO);
+ wishes = 1;
+ }
private boolean illegal = false;
if (bindingGroup != null) {
/*
for(int i=0; i<20 ; i++) {
- Point p2 = getConstraint().times(pp);
- pp = pp.midpoint(p2);
+ Point v2 = getConstraint().times(pp);
+ pp = pp.midpoint(v2);
//System.out.println(m.minus(m2));
}
*/