checkpoint
[anneal.git] / src / edu / berkeley / qfat / geom / Point.java
index 61fa603..a4bc276 100644 (file)
@@ -1,8 +1,9 @@
 package edu.berkeley.qfat.geom;
 import javax.media.opengl.*;
+import javax.media.opengl.glu.*;
 
 /** point in 3-space; immutable */
-public final class Point implements HasBoundingBox {
+public final class Point extends HasPoint implements HasBoundingBox {
     public final float x, y, z;
     public Point(double x, double y, double z) { this((float)x, (float)y, (float)z); }
     public Point(float x, float y, float z) { this.x = x; this.y = y; this.z = z; }
@@ -13,6 +14,7 @@ public final class Point implements HasBoundingBox {
 
     public Vec minus(Point p) { return new Vec(x-p.x, y-p.y, z-p.z); }
     public Point plus(Vec v) { return new Point(x+v.x, y+v.y, z+v.z); }
+    public Point midpoint(Point p) { return new Point((x+p.x)/2, (y+p.y)/2, (z+p.z)/2); }
 
     public void glVertex(GL gl) { gl.glVertex3f(x, y, z); }
 
@@ -21,6 +23,8 @@ public final class Point implements HasBoundingBox {
     public boolean equals(Object o) { return o!=null && (o instanceof Point) && ((Point)o).x==x && ((Point)o).y==y && ((Point)o).z==z; }
     public int hashCode() { return Float.floatToIntBits(x) ^ Float.floatToIntBits(y) ^ Float.floatToIntBits(z); }
 
+    public Point getPoint() { return this; }
+
     public float getMaxX() { return x; }
     public float getMinX() { return x; }
     public float getMaxY() { return y; }