From: adam Date: Mon, 26 Nov 2007 04:32:41 +0000 (-0800) Subject: checkpoint X-Git-Url: http://git.megacz.com/?p=anneal.git;a=commitdiff_plain;h=a18e40f15c9b054cdd16c3a5416a36a10033b632 checkpoint darcs-hash:20071126043241-5007d-01db63af80f2573f11f0fb94ac110291d8a7fb05.gz --- diff --git a/src/Geom.java b/src/Geom.java index 944ee61..9c639e1 100644 --- a/src/Geom.java +++ b/src/Geom.java @@ -9,7 +9,7 @@ public class Geom implements Iterable { private HashMap ps = new HashMap(); private HashMap es = new HashMap(); - private HashSet ts = new HashSet(); + private HashSet ts = new HashSet(); public Iterator iterator() { return ts.iterator(); } @@ -39,11 +39,11 @@ public class Geom implements Iterable { return new T(e1, e2, e3); } - /** point in 3-space */ + /** [UNIQUE] point in 3-space */ public final class P { public final float x, y, z; public P(float x, float y, float z) { this.x = x; this.y = y; this.z = z; } - public V minus(P p) { return null; } + public V minus(P p) { return new V(x-p.x, y-p.y, z-p.z); } public boolean equals(Object o) { if (o==null || !(o instanceof P)) return false; P p = (P)o; @@ -62,12 +62,13 @@ public class Geom implements Iterable { public final class V { private final float x, y, z; public V(float x, float y, float z) { this.x = x; this.y = y; this.z = z; } - public V norm() { return null; /* FIXME */ } public boolean sameDirection(V v) { throw new Error(); } - public V cross(V v) { return null; } + public V cross(V v) { return new V(y*v.z-z*v.y, z*v.x-x*v.z, x*v.y-y*v.x); } + public float mag() { return (float)Math.sqrt(x*x+y*y+z*z); } + public V norm() { float m = mag(); return new V(x/m, y/m, z/m); } } - /** an edge */ + /** [UNIQUE] an edge */ public final class E { public final P p1, p2; T t1, t2; @@ -96,7 +97,7 @@ public class Geom implements Iterable { } } - /** a triangle (face) */ + /** [UNIQUE] a triangle (face) */ public final class T { public final E e1, e2, e3; public T(E e1, E e2, E e3, V normal) { @@ -134,19 +135,6 @@ public class Geom implements Iterable { ts.add(this); } public boolean hasE(E e) { return e1==e || e2==e || e3==e; } - - // technically not required - /* - public int hashCode() { return e1.hashCode() ^ e2.hashCode() ^ e3.hashCode(); } - public boolean equals(Object o) { - if (o==null || !(o instanceof T)) return false; - T t = (T)o; - if (this.e1 == t.e1 && this.e2 == t.e2 && this.e3 == t.e3) return true; - if (this.e1 == t.e2 && this.e2 == t.e3 && this.e3 == t.e1) return true; - if (this.e1 == t.e3 && this.e2 == t.e1 && this.e3 == t.e2) return true; - return false; - } - */ public void glVertices(GL gl) { e1.unshared(e2).glVertex(gl); e1.shared(e2).glVertex(gl); diff --git a/src/Main.java b/src/Main.java index 64852c9..3acb5e0 100644 --- a/src/Main.java +++ b/src/Main.java @@ -10,18 +10,10 @@ public class Main implements GLEventListener { public Main(StlFile stlf) { for(int i=0; i