/** 3D location * @author: Phil Gage */ class Point /* extends Vector3 */ { public double x, y, z; Point () { this.x = 0.0; this.y = 0.0; this.z = 0.0; } Point (Point p) { this.x = p.x; this.y = p.y; this.z = p.z; } Point (double x, double y, double z) { this.x = x; this.y = y; this.z = z; } /** Copy a to this */ public void set (Point a) { this.x = a.x; this.y = a.y; this.z = a.z; } /** Copy a to this */ public void set (double x, double y, double z) { this.x = x; this.y = y; this.z = z; } public double dot (Vector3 v) { return x*v.x + y*v.y + z*v.z; } public Vector3 subtract (Point p) { return new Vector3 (x - p.x, y - p.y, z - p.z); } public double distance (Point p) { return Math.sqrt ((p.x-x)*(p.x-x) + (p.y-y)*(p.y-y) + (p.z-z)*(p.z-z)); } public String toString () { return "Point x=" + x + " y=" + y + " z=" + z; } }