//v = v.plus(v2.norm().times(1/(float)300));
v = v2.norm().times(1/(float)300);
- boolean good = p.move(v);
+ Matrix m = Matrix.translate(v);
+
+ boolean good = p.move(m, false);
if (!good) { misses++; return; }
p.reComputeErrorAround();
//System.out.println("error: " + tile_error + " / " + goal_error);
hits++;
} else {
- p.move(v.times(-1));
+ p.move(m.inverse(), true);
misses++;
}
}
}
/** does NOT update bound pairs! */
- public boolean transform(Point newp, boolean ignoreProblems) {
+ private boolean transform(Point newp, boolean ignoreProblems) {
this.oldp = this.p;
if (immutableVertices) throw new Error();
}
public boolean visit(Object o) {
- if (o instanceof T) {
- T t = (T)o;
- if (!good) return false;
- for(E e = Vertex.this.e; e!=null; e=e.pair.next==Vertex.this.e?null:e.pair.next) {
- if (!t.has(e.p1) && !t.has(e.p2) && e.intersects(t)) { good = false; }
- if (e.t != null) {
- if (!e.t.has(t.e1().p1) && !e.t.has(t.e1().p2) && t.e1().intersects(e.t)) { good = false; }
- if (!e.t.has(t.e2().p1) && !e.t.has(t.e2().p2) && t.e2().intersects(e.t)) { good = false; }
- if (!e.t.has(t.e3().p1) && !e.t.has(t.e3().p2) && t.e3().intersects(e.t)) { good = false; }
- }
+ if (o instanceof Vertex)
+ return ((Vertex)o).e != null && ((Vertex)o).norm().dot(Vertex.this.norm()) >= 0;
+ T t = (T)o;
+ if (!good) return false;
+ for(E e = Vertex.this.e; e!=null; e=e.pair.next==Vertex.this.e?null:e.pair.next) {
+ if (!t.has(e.p1) && !t.has(e.p2) && e.intersects(t)) { good = false; }
+ if (e.t != null) {
+ if (!e.t.has(t.e1().p1) && !e.t.has(t.e1().p2) && t.e1().intersects(e.t)) { good = false; }
+ if (!e.t.has(t.e2().p1) && !e.t.has(t.e2().p2) && t.e2().intersects(e.t)) { good = false; }
+ if (!e.t.has(t.e3().p1) && !e.t.has(t.e3().p2) && t.e3().intersects(e.t)) { good = false; }
}
- return good;
- } else {
- Vertex v = (Vertex)o;
- if (v.e==null || v.norm().dot(Vertex.this.norm()) < 0)
- return false;
- return true;
}
+ return good;
}
- public boolean move(Vec v) {
- Matrix m = Matrix.translate(v);
+ public boolean move(Matrix m, boolean ignoreProblems) {
boolean good = true;
for(Vertex p = this; p != null; p = (p.bound_to==this)?null:p.bound_to)
- good &= p.transform(m.times(p.p), false);
+ good &= p.transform(m.times(p.p), ignoreProblems);
for(Vertex p = this; p != null; p = (p.bound_to==this)?null:p.bound_to)
if (good) p.reComputeErrorAround();
else p.transform(p.oldp, true);