public static float EPSILON = (float)0.0001;
public static Random random = new Random();
- private HashMap<P,P> ps = new HashMap<P,P>();
+ private HashMap<P,V> ps = new HashMap<P,V>();
public HashSet<E> es = new HashSet<E>();
public ArrayList<T> ts = new ArrayList<T>();
public M aspect = new M();
public M invaspect = new M();
- /** [UNIQUE] point in 3-space */
- public final class P {
+ public final class V extends P {
+ public V(P p) {
+ super(p.x, p.y, p.z);
+ if (ps.get(p) != null) throw new Error();
+ ps.put(this, this);
+ }
+ }
+ public class P {
float x, y, z;
int watch_count;
private boolean inserted = false;
- public P register() {
- P p2 = ps.get(this);
- if (p2==null) { p2 = this; ps.put(this,this); }
- return p2;
+ public V register() {
+ V v = ps.get(this);
+ if (v==null) v = new V(this);
+ return (V)v;
}
public void kdremove() {
this.y = newy;
this.z = newz;
// FIXME: what if we move onto exactly where another point is?
- ps.put(this,this);
+ ps.put((V)this,(V)this);
} catch (Exception e) {
throw new RuntimeException(e);
}