Random random = new Random();
public synchronized void breakit() {
- if (verts > 200) return;
+ if (verts > 400) return;
//double min = (tile.avgedge/tile.numedges)*(1+(4/(double)verts));
//if (verts>0 && tile.es.peek().length() < min) return;
PriorityQueue<Mesh.E> es = new PriorityQueue<Mesh.E>();
Vec v = p.nearest_vert_in_other_mesh().minus(p.p).norm().times(r1);
*/
//v = p.norm().times(v.dot(p.norm()));
- /*
+
Vec v = new Vec((random.nextFloat() - (float)0.5) / 1000,
(random.nextFloat() - (float)0.5) / 1000,
(random.nextFloat() - (float)0.5) / 1000);
- */
+ /*
Matrix inv = p.errorQuadric();
Vec v = new Vec(inv.d, inv.h, inv.l).norm().times(1/(float)1000);
-
+ */
boolean aspect = false;//(Math.abs(random.nextInt()) % 100) <= 2;
Matrix old_tile_aspect = null;//goal.aspect;
boolean good = true;
double new_tile_score = tile.score();
double new_goal_score = goal.score();
double tile_delta = new_tile_score - tile_score;
- double goal_delta = new_goal_score - goal_score;
+ double goal_delta = 0;//new_goal_score - goal_score;
double delta = tile_delta + goal_delta;
double swapProbability = Math.exp((-1 * delta) / temperature);
//boolean doSwap = Math.random() < swapProbability;
boolean doSwap = good && (tile_delta <= 0 && goal_delta <= 0);
+ //boolean doSwap = true;
//System.out.println(doSwap);
if (doSwap) {
tile_score = new_tile_score;
goal_score = new_goal_score;
- //System.out.println("score: " + tile_score + " / " + goal_score);
+ System.out.println("score: " + tile_score + " / " + goal_score);
if (aspect) System.out.println("aspect " + v);
} else {
if (aspect) {
for(Mesh.Vert p : new Mesh.Vert[] { t.v1(), t.v2(), t.v3() }) {
rand(10,p);
}
+ goal.unscore();
+ tile.unscore();
+ goal.fundamental();
+ tile.fundamental();
goal.rescore();
tile.rescore();
}
}
}
+ public void unscore() {
+ HashSet<Vert> done = new HashSet<Vert>();
+ for(T t : this)
+ for(Vert p : new Vert[] { t.v1(), t.v2(), t.v3() }) {
+ if (done.contains(p)) continue;
+ done.add(p);
+ p.unscore();
+ }
+ }
+ public void fundamental() {
+ HashSet<Vert> done = new HashSet<Vert>();
+ for(T t : this)
+ for(Vert p : new Vert[] { t.v1(), t.v2(), t.v3() }) {
+ if (done.contains(p)) continue;
+ done.add(p);
+ p.recomputeFundamentalQuadric();
+ }
+ }
public float rescore() {
int num = 0;
double dist = 0;
for(Vert p : new Vert[] { t.v1(), t.v2(), t.v3() }) {
if (done.contains(p)) continue;
done.add(p);
- //p.rescore();
- p.recomputeFundamentalQuadric();
+ p.rescore();
+
}
return (float)(dist/num);
}
s2 = quadric==null ? 0 : po.p.distance(quadric.p);
oldscore = (float)(s1 + s2);
*/
- oldscore = quadric.preAndPostMultiply(p);
+ oldscore = quadric_count == 0 ? 0 : (quadric.preAndPostMultiply(p) / quadric_count);
score += oldscore;
}