checkpoint
[anneal.git] / src / edu / berkeley / qfat / Main.java
index e4abd5a..237266b 100644 (file)
@@ -6,7 +6,9 @@ import javax.swing.*;
 import javax.media.opengl.*;
 import javax.media.opengl.glu.*;
 import java.util.*;
+import edu.berkeley.qfat.bind.*;
 import edu.berkeley.qfat.geom.*;
+import edu.berkeley.qfat.stl.*;
 import edu.berkeley.qfat.geom.Point;
 import edu.berkeley.qfat.geom.Polygon;
 
@@ -77,7 +79,7 @@ import edu.berkeley.qfat.geom.Polygon;
 
 public class Main extends InteractiveMeshViewer {
 
-    public Matrix[] transforms;
+
 
     public static int verts = 1;
 
@@ -97,7 +99,7 @@ public class Main extends InteractiveMeshViewer {
                 if (v.mag() < 0.0001) continue;
                 v = v.times(-1);
                 v = v.times(0.5f);
-                Point p = Point.ORIGIN.plus(v);
+                Point p = Point.ZERO.plus(v);
                 v = v.times(-1);
                 
                 //System.out.println(v);
@@ -106,7 +108,7 @@ public class Main extends InteractiveMeshViewer {
                 polygons.add(new Polygon(hs));
         }
         for(Polygon p : polygons) {
-            System.out.println(p.plane.norm + " " + p.plane.dvalue);
+            System.out.println(p.plane.norm() + " " + p.plane.d);
             for(HalfSpace hs : halfSpaces) {
                 if (p.plane==hs) continue;
                 p = p.intersect(hs);
@@ -521,9 +523,9 @@ public class Main extends InteractiveMeshViewer {
                         es.add(t.e3());
                     }
                     for(Mesh.E e : es) {
-                        if (e.p1.p.x == e.p2.p.x && e.p1.p.y == e.p2.p.y) continue;
-                        if (e.p1.p.z == e.p2.p.z && e.p1.p.y == e.p2.p.y) continue;
-                        if (e.p1.p.x == e.p2.p.x && e.p1.p.z == e.p2.p.z) continue;
+                        if (e.v1.p.x == e.v2.p.x && e.v1.p.y == e.v2.p.y) continue;
+                        if (e.v1.p.z == e.v2.p.z && e.v1.p.y == e.v2.p.y) continue;
+                        if (e.v1.p.x == e.v2.p.x && e.v1.p.z == e.v2.p.z) continue;
                         e.shatter();
                     }
                     transforms = new Matrix[] {
@@ -784,7 +786,7 @@ public class Main extends InteractiveMeshViewer {
                 //Matrix m = Matrix.scale(1f, 2.1f, 1f);
                 tile.transform(m);
                 for(int i=0; i<transforms.length; i++)
-                    transforms[i] = transforms[i].preMultiplyTranslationalComponentBy(m);
+                    transforms[i] = preMultiplyTranslationalComponentBy(transforms[i], m);
                 fixupTile();
 
             } });
@@ -1003,4 +1005,12 @@ public class Main extends InteractiveMeshViewer {
 
     }
 
+    private static Matrix preMultiplyTranslationalComponentBy(Matrix mthis, Matrix mm) {
+        Vec v = mm.times(mthis.getTranslationalComponent());
+        return new Matrix(mthis.a, mthis.b, mthis.c, v.x,
+                          mthis.e, mthis.f, mthis.g, v.y,
+                          mthis.i, mthis.j, mthis.k, v.z,
+                          mthis.m, mthis.n, mthis.o, 1);
+    }
+
 }
\ No newline at end of file