public static float EPSILON = (float)0.0001;
public static Random random = new Random();
- private HashMap<Point,Vert> ps = new HashMap<Point,Vert>();
- //public HashSet<E> es = new HashSet<E>();
+ private HashMap<Point,Vert> verts = new HashMap<Point,Vert>();
public Iterable<E> edges() {
return
}
public Iterator<T> iterator() {
- for(Vert v : ps.values()) {
- if (v.e != null && v.e.t != null) return new FaceIterator(v);
- }
+ for(Vert v : verts.values())
+ if (v.e != null && v.e.t != null)
+ return new FaceIterator(v);
return new FaceIterator();
}
public void transform(Matrix m) {
ArrayList<Vert> set = new ArrayList<Vert>();
- set.addAll(ps.values());
+ set.addAll(verts.values());
for(Vert v : set) v.transform(m);
}
float max_x = Float.MIN_VALUE;
float max_y = Float.MIN_VALUE;
float max_z = Float.MIN_VALUE;
- for(Point p : ps.keySet()) {
+ for(Point p : verts.keySet()) {
if (p.x < min_x) min_x = p.x;
if (p.y < min_y) min_y = p.y;
if (p.z < min_z) min_z = p.z;
float max_x = Float.MIN_VALUE;
float max_y = Float.MIN_VALUE;
float max_z = Float.MIN_VALUE;
- for(Point p : ps.keySet()) {
+ for(Point p : verts.keySet()) {
if (p.x < min_x) min_x = p.x;
if (p.y < min_y) min_y = p.y;
if (p.z < min_z) min_z = p.z;
}
}
- public Vert register(Point p) { Vert v = ps.get(p); return v==null ? new Vert(p) : v; }
+ public Vert register(Point p) { Vert v = verts.get(p); return v==null ? new Vert(p) : v; }
public final class Vert {
public Point p;
private Vert(Point p) {
this.p = p;
- if (ps.get(p) != null) throw new Error();
- ps.put(this.p, this);
+ if (verts.get(p) != null) throw new Error();
+ verts.put(this.p, this);
}
public void kdremove() {
if (!inserted) return;
// FIXME: screws up hashmap
unscore();
try {
- if (ps.get(this.p)==null) throw new Error();
- ps.remove(this.p);
+ if (verts.get(this.p)==null) throw new Error();
+ verts.remove(this.p);
float newx = m.a*p.x + m.b*p.y + m.c*p.z + m.d;
float newy = m.e*p.x + m.f*p.y + m.g*p.z + m.h;
float newz = m.i*p.x + m.j*p.y + m.k*p.z + m.l;
this.p = new Point(newx, newy, newz);
// FIXME: what if we move onto exactly where another point is?
- ps.put(this.p,(Vert)this);
+ verts.put(this.p,(Vert)this);
} catch (Exception e) {
throw new RuntimeException(e);
}
if (norm != null) {
Vec norm2 = p3.p.minus(p1.p).cross(p2.p.minus(p1.p));
float dot = norm.dot(norm2);
- //if (Math.abs(dot) < EPointSILON) throw new Error("dot products within epsilon of each other: "+norm+" "+norm2);
+ //if (Math.abs(dot) < EPointSILON) throw new Error("dot products within evertsilon of each other: "+norm+" "+norm2);
if (dot < 0) { Vert p = p1; p1=p2; p2 = p; }
}
E e12 = p1.makeE(p2);