add RTree classes
[anneal.git] / src / edu / berkeley / qfat / geom / Point.java
1 package edu.berkeley.qfat.geom;
2 import javax.media.opengl.*;
3
4 /** point in 3-space; immutable */
5 public final class Point implements HasBoundingBox {
6     public final float x, y, z;
7     public Point(double x, double y, double z) { this((float)x, (float)y, (float)z); }
8     public Point(float x, float y, float z) { this.x = x; this.y = y; this.z = z; }
9     public float distance(Point p) { return distance(p.x, p.y, p.z); }
10     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)); }
11     public Point times(Matrix m) { return m.times(this); }
12     public Vec minus(Point p) { return new Vec(x-p.x, y-p.y, z-p.z); }
13     public Point plus(Vec v) { return new Point(x+v.x, y+v.y, z+v.z); }
14     public boolean equals(Object o) { return o!=null && (o instanceof Point) && ((Point)o).x==x && ((Point)o).y==y && ((Point)o).z==z; }
15     public void glVertex(GL gl) { _glVertex(gl); }
16     private void _glVertex(GL gl) { gl.glVertex3f(x, y, z); }
17     public String toString() { return "("+x+","+y+","+z+")"; }
18     public int hashCode() { return Float.floatToIntBits(x) ^ Float.floatToIntBits(y) ^ Float.floatToIntBits(z); }
19
20     public float getMaxX() { return x; }
21     public float getMinX() { return x; }
22     public float getMaxY() { return y; }
23     public float getMinY() { return y; }
24     public float getMaxZ() { return z; }
25     public float getMinZ() { return z; }
26 }