X-Git-Url: http://git.megacz.com/?p=anneal.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fqfat%2Fgeom%2FPoint.java;h=fdef5e647a5891074a232947066cfe380850c978;hp=5511e4415673013873e8ff9ce7c3d8cb77895164;hb=2b09dab499516873839b9bdbc972c980829e9bac;hpb=0f9ce20a060db6537a47b549cbf24fd268699ac6 diff --git a/src/edu/berkeley/qfat/geom/Point.java b/src/edu/berkeley/qfat/geom/Point.java index 5511e44..fdef5e6 100644 --- a/src/edu/berkeley/qfat/geom/Point.java +++ b/src/edu/berkeley/qfat/geom/Point.java @@ -6,15 +6,22 @@ public final class Point 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; } - public float distance(Point p) { return distance(p.x, p.y, p.z); } - public float distance(float ox, float oy, float oz) { return (float)Math.sqrt((x-ox)*(x-ox)+(y-oy)*(y-oy)+(z-oz)*(z-oz)); } + + public static final Point ORIGIN = new Point(0,0,0); + + public float distance(Point p) { return (float)Math.sqrt((x-p.x)*(x-p.x)+(y-p.y)*(y-p.y)+(z-p.z)*(z-p.z)); } + + // FIXME: this should be eliminated; wrong order public Point times(Matrix m) { return m.times(this); } + 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 boolean equals(Object o) { return o!=null && (o instanceof Point) && ((Point)o).x==x && ((Point)o).y==y && ((Point)o).z==z; } - public void glVertex(GL gl) { _glVertex(gl); } - private void _glVertex(GL gl) { gl.glVertex3f(x, y, z); } + + public void glVertex(GL gl) { gl.glVertex3f(x, y, z); } + public String toString() { return "("+x+","+y+","+z+")"; } + + 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 float getMaxX() { return x; } @@ -24,3 +31,4 @@ public final class Point implements HasBoundingBox { public float getMaxZ() { return z; } public float getMinZ() { return z; } } +