From: adam Date: Sun, 16 Dec 2007 03:56:36 +0000 (-0800) Subject: checkpoint X-Git-Url: http://git.megacz.com/?p=anneal.git;a=commitdiff_plain;h=9a1ec8473473464f51caeb04bd22179b977cad13 checkpoint darcs-hash:20071216035636-5007d-cd2cc4add44e67b4f7defc9a9555e5bc10a94834.gz --- diff --git a/src/edu/berkeley/qfat/Main.java b/src/edu/berkeley/qfat/Main.java index 8c38913..810173a 100644 --- a/src/edu/berkeley/qfat/Main.java +++ b/src/edu/berkeley/qfat/Main.java @@ -307,7 +307,9 @@ public class Main extends MeshViewer { //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(); @@ -327,7 +329,7 @@ public class Main extends MeshViewer { //System.out.println("error: " + tile_error + " / " + goal_error); hits++; } else { - p.move(v.times(-1)); + p.move(m.inverse(), true); misses++; } } diff --git a/src/edu/berkeley/qfat/Mesh.java b/src/edu/berkeley/qfat/Mesh.java index 6fd53d3..5c913c4 100644 --- a/src/edu/berkeley/qfat/Mesh.java +++ b/src/edu/berkeley/qfat/Mesh.java @@ -129,7 +129,7 @@ public class Mesh implements Iterable { } /** 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(); @@ -169,31 +169,25 @@ public class Mesh implements Iterable { } 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);