X-Git-Url: http://git.megacz.com/?p=anneal.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fqfat%2FMain.java;h=6c663d01f36ffe372c05b78547611b3c58cc2681;hp=8607e0adfd02d958fdda3b7007e02f1c24a2964c;hb=116e33cf3c02f4935571766ed5509d0ed95551b8;hpb=b1832d008534acfc7fe0dc8677387ed1016a5b38 diff --git a/src/edu/berkeley/qfat/Main.java b/src/edu/berkeley/qfat/Main.java index 8607e0a..6c663d0 100644 --- a/src/edu/berkeley/qfat/Main.java +++ b/src/edu/berkeley/qfat/Main.java @@ -5,7 +5,8 @@ import javax.swing.*; import javax.media.opengl.*; import javax.media.opengl.glu.*; import java.util.*; -import static edu.berkeley.qfat.Geom.*; +import edu.berkeley.qfat.geom.*; +import edu.berkeley.qfat.geom.Point; // FIXME: recenter goal to have centroid coincident with tile // FIXME: re-orient goal (how?) @@ -67,70 +68,70 @@ public class Main implements GLEventListener, MouseListener, MouseMotionListener mousey = e.getY(); } - private Geom tile = new Geom(); - private Geom goal = new Geom(); + private Mesh tile = new Mesh(); + private Mesh goal = new Mesh(); /** magnification factor */ private static final float MAG = 1; - Geom.M[] translations; - Geom.Vert[] points; + Matrix[] translations; + Mesh.Vert[] points; public Main(StlFile stlf) { for(int i=0; i 300) return; //double min = (tile.avgedge/tile.numedges)*(1+(4/(double)verts)); //if (verts>0 && tile.es.peek().length() < min) return; - PriorityQueue es = new PriorityQueue(); - for(Geom.E e : tile.es) es.add(e); + PriorityQueue es = new PriorityQueue(); + for(Mesh.E e : tile.edges()) es.add(e); for(int i=0; i<10; i++) { - Geom.E e = es.poll(); + Mesh.E e = es.poll(); verts++; System.out.println("shatter " + e); e.shatter(); @@ -253,7 +259,7 @@ public class Main implements GLEventListener, MouseListener, MouseMotionListener } } - public synchronized void rand(double temperature, Geom.Vert p) { + public synchronized void rand(double temperature, Mesh.Vert p) { double tile_score = tile.score(); double goal_score = goal.score(); @@ -263,18 +269,18 @@ public class Main implements GLEventListener, MouseListener, MouseMotionListener r1 = r1 - (float)Math.floor(r1); r1 = r1 * (float)0.01; r1 = r1 - (float)0.005; - Geom.Vec v = p.watchback().p.minus(p.p).norm().times(r1); + Vec v = p.watchback().minus(p.p).norm().times(r1); //v = p.norm().times(v.dot(p.norm())); boolean aspect = false;//(Math.abs(random.nextInt()) % 100) <= 2; - Geom.M old_tile_aspect = null;//goal.aspect; + Matrix old_tile_aspect = null;//goal.aspect; boolean good = true; if (aspect) { /* v = v.times(10); - tile.aspect = new Geom.M(tile.aspect.a / (v.x+1), tile.aspect.f / (v.y+1), tile.aspect.k / (v.z+1)); - tile.invaspect = new Geom.M(1/tile.aspect.a, 1/tile.aspect.f, 1/tile.aspect.k); + tile.aspect = new Matrix(tile.aspect.a / (v.x+1), tile.aspect.f / (v.y+1), tile.aspect.k / (v.z+1)); + tile.invaspect = new Matrix(1/tile.aspect.a, 1/tile.aspect.f, 1/tile.aspect.k); goal.rescore(); tile.rescore(); */ @@ -297,7 +303,7 @@ public class Main implements GLEventListener, MouseListener, MouseMotionListener } else { if (aspect) { //tile.aspect = old_tile_aspect; - //tile.invaspect = new Geom.M(1/tile.aspect.a, 1/tile.aspect.f, 1/tile.aspect.k); + //tile.invaspect = new Matrix(1/tile.aspect.a, 1/tile.aspect.f, 1/tile.aspect.k); goal.rescore(); tile.rescore(); } else { @@ -349,12 +355,12 @@ public class Main implements GLEventListener, MouseListener, MouseMotionListener int i = 0; //gl.glDisable(GL.GL_DEPTH_TEST); gl.glColor4f(1,1,1,1); - for(Geom.M m : translations) { + for(Matrix m : translations) { //if (v1.z==0 && v1.y==0) continue; i++; if (i != 1 /*&& i!=4*/) continue; - Geom.Point p = new Geom.Point(0, 0, 0).times(m); - Geom.Vec v = new Geom.Vec(p.x, p.y, p.z); + Point p = new Point(0, 0, 0).times(m); + Vec v = new Vec(p.x, p.y, p.z); v = v.times((float)1.04); gl.glTranslatef(v.x, v.y, v.z); draw(gl, false, tile); @@ -363,11 +369,11 @@ public class Main implements GLEventListener, MouseListener, MouseMotionListener //gl.glEnable(GL.GL_DEPTH_TEST); } - private synchronized void draw(GL gl, boolean triangles, Geom mesh) { + private synchronized void draw(GL gl, boolean triangles, Mesh mesh) { float red = 0.0f; float green = 0.0f; float blue = 0.0f; - for(Geom.T t : mesh) { + for(Mesh.T t : mesh) { if (red < 0.15) red = 1.0f; if (green < 0.15) green = 1.0f; if (blue < 0.15) blue = 1.0f; @@ -398,7 +404,7 @@ public class Main implements GLEventListener, MouseListener, MouseMotionListener gl.glEnd(); } - Geom.Point centroid = t.centroid(); + Point centroid = t.centroid(); gl.glBegin(GL.GL_LINES); gl.glColor3f(1, 1, 1); /* @@ -407,7 +413,7 @@ public class Main implements GLEventListener, MouseListener, MouseMotionListener */ if (mesh==goal) - for(Geom.Vert p : new Geom.Vert[] { t.p1(), t.p2(), t.p3() }) { + for(Mesh.Vert p : new Mesh.Vert[] { t.v1(), t.v2(), t.v3() }) { p.p.glVertex(gl); //p.plus(p.norm().times(p.score()*10)).glVertex(gl); p.partner().p.glVertex(gl); @@ -448,8 +454,8 @@ public class Main implements GLEventListener, MouseListener, MouseMotionListener for(int i=0; i<1; i++) { glcanvas.repaint(); //tile.ts.get(Math.abs(random.nextInt()) % tile.ts.size()).e1().p1 - for(Geom.T t : tile) - for(Geom.Vert p : new Geom.Vert[] { t.p1(), t.p2(), t.p3() }) { + for(Mesh.T t : tile) + for(Mesh.Vert p : new Mesh.Vert[] { t.v1(), t.v2(), t.v3() }) { rand(10,p); } goal.rescore();