From 1229f4eaa0337691b51ecd3e0baebddc2644f2c3 Mon Sep 17 00:00:00 2001 From: adam Date: Wed, 5 Dec 2007 00:09:47 -0800 Subject: [PATCH] checkpoint darcs-hash:20071205080947-5007d-f838d6936598536875c234ecbf0604273bda81dc.gz --- src/edu/berkeley/qfat/Main.java | 2 +- src/edu/berkeley/qfat/Mesh.java | 26 +++++++++++++++----------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/edu/berkeley/qfat/Main.java b/src/edu/berkeley/qfat/Main.java index 55eefd9..c4dcf5a 100644 --- a/src/edu/berkeley/qfat/Main.java +++ b/src/edu/berkeley/qfat/Main.java @@ -193,7 +193,7 @@ public class Main extends MeshViewer { public synchronized void rand(double temperature, Mesh.Vert p) { double tile_score = tile.score(); double goal_score = goal.score(); - p.applyQuadricToNeighbor(); + p.reComputeError(); Vec v = new Vec((random.nextFloat() - (float)0.5) / 1000, (random.nextFloat() - (float)0.5) / 1000, diff --git a/src/edu/berkeley/qfat/Mesh.java b/src/edu/berkeley/qfat/Mesh.java index 55052b9..74ccd4b 100644 --- a/src/edu/berkeley/qfat/Mesh.java +++ b/src/edu/berkeley/qfat/Mesh.java @@ -186,19 +186,15 @@ public class Mesh implements Iterable { public void unApplyQuadricToNeighbor() { if (nearest_in_other_mesh == null) return; if (fundamentalQuadric == null) return; - nearest_in_other_mesh.unsc(); + nearest_in_other_mesh.unComputeError(); nearest_in_other_mesh.quadric = nearest_in_other_mesh.quadric.minus(fundamentalQuadric); nearest_in_other_mesh.quadric_count--; if (nearest_in_other_mesh.quadric_count==0) nearest_in_other_mesh.quadric = Matrix.ZERO; - nearest_in_other_mesh.resc(); + nearest_in_other_mesh.computeError(); nearest_in_other_mesh = null; } - public void unsc() { - score -= oldscore; - oldscore = 0; - } public void applyQuadricToNeighbor() { if (score_against == null) return; @@ -210,16 +206,24 @@ public class Mesh implements Iterable { if (nearest_in_other_mesh.e == null || nearest_in_other_mesh.norm().dot(norm()) < 0) { nearest_in_other_mesh = null; } else { - nearest_in_other_mesh.unsc(); + nearest_in_other_mesh.unComputeError(); nearest_in_other_mesh.quadric = nearest_in_other_mesh.quadric.plus(fundamentalQuadric()); nearest_in_other_mesh.quadric_count++; - nearest_in_other_mesh.resc(); + nearest_in_other_mesh.computeError(); } } - unsc(); - resc(); + reComputeError(); + } + + public void reComputeError() { + unComputeError(); + computeError(); + } + public void unComputeError() { + score -= oldscore; + oldscore = 0; } - public void resc() { + public void computeError() { oldscore = quadric_count == 0 ? 0 : (quadric.preAndPostMultiply(p) / quadric_count); score += oldscore; } -- 1.7.10.4