public class Vec{ private double x,y,z; public Vec (double a, double b, double c){ x = a; y = b; z = c; } public double dot (Vec w){ return this.x * w.x + this.y * w.y + this.z * w.z; } public Vec cross (Vec w){ double newX = this.y * w.z - this.z * w.y; double newY = this.z * w.x - this.x * w.z; double newZ = this.x * w.y - this.y * w.x; return new Vec (newX, newY, newZ); } public double length(){ return Math.sqrt (this.dot(this)); } public String toString(){ return "(" + this.x + "," + this.y + "," + this.z + ")"; } }