translations = new Matrix[] {
- /*
+
Matrix.translate(new Vec(0, 0.2f,0))
- .times(Matrix.rotate(new Vec(0,1,0), (float)( 1*Math.PI/2))),
+ .times(Matrix.rotate(new Vec(0,1,0), (float)(1*Math.PI/2))),
Matrix.translate(new Vec(0,-0.2f,0))
- .times(Matrix.rotate(new Vec(0,1,0), (float)(-1*Math.PI/2))),
+ .times(Matrix.rotate(new Vec(0,1,0), (float)(1*Math.PI/2))),
Matrix.translate(new Vec( 0.2f,0,0))
- .times(Matrix.rotate(new Vec(1,0,0), (float)( 1*Math.PI/2))),
+ .times(Matrix.rotate(new Vec(1,0,0), (float)(-1*Math.PI/2))),
Matrix.translate(new Vec(-0.2f,0,0))
.times(Matrix.rotate(new Vec(1,0,0), (float)(-1*Math.PI/2))),
- */
+
/*
Matrix.rotate(new Vec(0,0,1), (float)(1*Math.PI/2)),
Matrix.rotate(new Vec(0,0,1), (float)(2*Math.PI/2)),
Matrix.rotate(new Vec(0,0,1), (float)(3*Math.PI/2)),
- */
- Matrix.rotate(new Vec(1,0,0), (float)(2*Math.PI/2)),
+ Matrix.rotate(new Vec(1,0,0), (float)(2*Math.PI/2)),
+ */
//Matrix.rotate(new Vec(0,0,1), (float)(2*Math.PI/2)),
//Matrix.scale(1,-1,1),
for(Matrix m2 : translations) {
for(Mesh.T t1 : tile) {
for(Mesh.T t2 : tile) {
- if (t1==t2) continue;
Matrix m = m1.inverse().times(m2);
- if ((t1.v1().p.times(m).minus(t2.v1().p).mag() < MATCHING_EPSILON) &&
- (t1.v2().p.times(m).minus(t2.v3().p).mag() < MATCHING_EPSILON) &&
- (t1.v3().p.times(m).minus(t2.v2().p).mag() < MATCHING_EPSILON)) {
+ if ((t1.v1().p.times(m).distance(t2.v1().p) < MATCHING_EPSILON) &&
+ (t1.v2().p.times(m).distance(t2.v3().p) < MATCHING_EPSILON) &&
+ (t1.v3().p.times(m).distance(t2.v2().p) < MATCHING_EPSILON)) {
t2.e3().bindEdge(t1.e1(), m);
t2.e2().bindEdge(t1.e2(), m);
t2.e1().bindEdge(t1.e3(), m);
}
- if ((t1.v2().p.times(m).minus(t2.v1().p).mag() < MATCHING_EPSILON) &&
- (t1.v3().p.times(m).minus(t2.v3().p).mag() < MATCHING_EPSILON) &&
- (t1.v1().p.times(m).minus(t2.v2().p).mag() < MATCHING_EPSILON)) {
+ if ((t1.v2().p.times(m).distance(t2.v1().p) < MATCHING_EPSILON) &&
+ (t1.v3().p.times(m).distance(t2.v3().p) < MATCHING_EPSILON) &&
+ (t1.v1().p.times(m).distance(t2.v2().p) < MATCHING_EPSILON)) {
t2.e3().bindEdge(t1.e2(), m);
t2.e2().bindEdge(t1.e3(), m);
t2.e1().bindEdge(t1.e1(), m);
}
- if ((t1.v3().p.times(m).minus(t2.v1().p).mag() < MATCHING_EPSILON) &&
- (t1.v1().p.times(m).minus(t2.v3().p).mag() < MATCHING_EPSILON) &&
- (t1.v2().p.times(m).minus(t2.v2().p).mag() < MATCHING_EPSILON)) {
+ if ((t1.v3().p.times(m).distance(t2.v1().p) < MATCHING_EPSILON) &&
+ (t1.v1().p.times(m).distance(t2.v3().p) < MATCHING_EPSILON) &&
+ (t1.v2().p.times(m).distance(t2.v2().p) < MATCHING_EPSILON)) {
t2.e3().bindEdge(t1.e3(), m);
t2.e2().bindEdge(t1.e1(), m);
t2.e1().bindEdge(t1.e2(), m);
}
- if ((t1.v1().p.times(m).minus(t2.v1().p).mag() < MATCHING_EPSILON) &&
- (t1.v2().p.times(m).minus(t2.v2().p).mag() < MATCHING_EPSILON) &&
- (t1.v3().p.times(m).minus(t2.v3().p).mag() < MATCHING_EPSILON)) {
+ if ((t1.v1().p.times(m).distance(t2.v1().p) < MATCHING_EPSILON) &&
+ (t1.v2().p.times(m).distance(t2.v2().p) < MATCHING_EPSILON) &&
+ (t1.v3().p.times(m).distance(t2.v3().p) < MATCHING_EPSILON)) {
t2.e1().bindEdge(t1.e1().pair, m);
t2.e2().bindEdge(t1.e2().pair, m);
t2.e3().bindEdge(t1.e3().pair, m);
}
- if ((t1.v2().p.times(m).minus(t2.v1().p).mag() < MATCHING_EPSILON) &&
- (t1.v3().p.times(m).minus(t2.v2().p).mag() < MATCHING_EPSILON) &&
- (t1.v1().p.times(m).minus(t2.v3().p).mag() < MATCHING_EPSILON)) {
+ if ((t1.v2().p.times(m).distance(t2.v1().p) < MATCHING_EPSILON) &&
+ (t1.v3().p.times(m).distance(t2.v2().p) < MATCHING_EPSILON) &&
+ (t1.v1().p.times(m).distance(t2.v3().p) < MATCHING_EPSILON)) {
t2.e2().bindEdge(t1.e1().pair, m);
t2.e3().bindEdge(t1.e2().pair, m);
t2.e1().bindEdge(t1.e3().pair, m);
}
- if ((t1.v3().p.times(m).minus(t2.v1().p).mag() < MATCHING_EPSILON) &&
- (t1.v1().p.times(m).minus(t2.v2().p).mag() < MATCHING_EPSILON) &&
- (t1.v2().p.times(m).minus(t2.v3().p).mag() < MATCHING_EPSILON)) {
+ if ((t1.v3().p.times(m).distance(t2.v1().p) < MATCHING_EPSILON) &&
+ (t1.v1().p.times(m).distance(t2.v2().p) < MATCHING_EPSILON) &&
+ (t1.v2().p.times(m).distance(t2.v3().p) < MATCHING_EPSILON)) {
t2.e3().bindEdge(t1.e1().pair, m);
t2.e1().bindEdge(t1.e2().pair, m);
t2.e2().bindEdge(t1.e3().pair, m);
float factor = (float)Math.pow(tile.volume() / goal.volume(), 1.0/3.0);
- goal.transform(Matrix.scale(factor/2.4f));
+ goal.transform(Matrix.scale(factor/2.1f));
goal.transform(Matrix.rotate(new Vec(0, 1, 0), (float)(Math.PI/2)));
// translate to match centroid
//System.out.println(v.mag() + " " + max);
boolean good = p.move(m, false);
- //if (!good) { /*misses++;*/ return; }
+ if (!good) { /*misses++;*/ return; }
double new_tile_error = tile.error();
double new_goal_error = goal.error();
p.move(Matrix.translate(v.times(-1)), true);
misses++;
}
+ p.reComputeErrorAround();
}
float hits = 0;
System.out.println("temp="+temp + " ratio="+(Math.ceil(acceptance*100)) + " " +
"points_per_second=" +
(count*1000)/((double)(System.currentTimeMillis()-then)));
- for(Mesh.Vertex p : goal.vertices()) p.recomputeFundamentalQuadricIfNeighborChanged();
+ for(Mesh.Vertex p : goal.vertices()) {
+ p.quadricStale = true;
+ p.recomputeFundamentalQuadricIfNeighborChanged();
+ }
synchronized(safeTriangles) {
safeTriangles.clear();
throw new Error(v.p+" "+pt2+"\n"+op+" "+pt+"\n"+v.getBindingMatrix(this));
if (Math.abs( v.p.minus(pt2).mag() / pt.minus(op).mag() ) < 1/5) throw new Error();
*/
- good &= v.transform(pt2,
- ignoreProblems, v.getBindingMatrix(this));
+ good &= v.transform(pt2, ignoreProblems, v.getBindingMatrix(this));
+ }
+
+ if (!good) {
+ for(Vertex v : (Iterable<Vertex>)getBoundPeers())
+ v.transform(v.oldp, true, null);
}
for(Vertex v : (Iterable<Vertex>)getBoundPeers())
v.recomputeFundamentalQuadricIfNeighborChanged();
+ for(Vertex v : (Iterable<Vertex>)getBoundPeers())
+ v.reComputeErrorAround();
return good;
}
Point mid = e.midpoint();
Vertex r = e.next.p2;
Vertex l = e.pair.next.p2;
- e.destroy();
- e.pair.destroy();
- newT(r.p, e.p1.p, mid, null, 0);
- newT(r.p, mid, e.p2.p, null, 0);
- newT(l.p, mid, e.p1.p, null, 0);
- newT(l.p, e.p2.p, mid, null, 0);
+ if (!e.destroyed) {
+ e.destroy();
+ e.pair.destroy();
+ newT(r.p, e.p1.p, mid, null, 0);
+ newT(r.p, mid, e.p2.p, null, 0);
+ newT(l.p, mid, e.p1.p, null, 0);
+ newT(l.p, e.p2.p, mid, null, 0);
+ }
}
for(E e : (Iterable<E>)getBoundPeers()) {
Point mid = e.midpoint();
e.p1.getE(mid).pair. bindTo(e.getBindingMatrix(firste), first.pair);
e.p2.getE(mid).pair. bindTo(e.getBindingMatrix(firste), firstq);
e.p2.getE(mid).pair.pair.bindTo(e.getBindingMatrix(firste), firstq.pair);
+ first.bindingGroup.setKrank(e.bindingGroup.krank);
+ firstq.bindingGroup.setKrank(e.bindingGroup.krank);
+ first.pair.bindingGroup.setKrank(e.bindingGroup.krank);
+ firstq.pair.bindingGroup.setKrank(e.bindingGroup.krank);
}
return null;
}