import java.lang.Math;

public class Point3D {
	public float p[];
	public Point3D () {
		p = new float[3];
		p[0] = (float)0.0;
		p[1] = (float)0.0;
		p[2] = (float)0.0;
	}

	public Point3D (float i, float j, float k) {
		p = new float[3];
		p[0] = i;
		p[1] = j;
		p[2] = k;
	}

	public Point3D (Point3D copy) {
		p = new float[3];
		p[0] = copy.p[0];
		p[1] = copy.p[1];
		p[2] = copy.p[2];
	}

	public float getX() { return p[0]; }
	public float getY() { return p[1]; }
	public float getZ() { return p[2]; }

	public void subtract(Point3D sub) {
		p[0] -= sub.p[0];
		p[1] -= sub.p[1];
		p[2] -= sub.p[2];
	}

	public void normalize() {
		double length = Math.sqrt((double)
								  (p[0]*p[0] +
								   p[1]*p[1] +
								   p[2]*p[2]));
		p[0] /= (float) length;
		p[1] /= (float) length;
		p[2] /= (float) length;
	}

	public float dot(Point3D b) {
		return ((p[0] * b.p[0]) +
			    (p[1] * b.p[1]) +
				(p[2] * b.p[2]));
	}

	public void negate() {
		p[0] = -1 * p[0];
		p[1] = -1 * p[1];
		p[2] = -1 * p[2];
	}
}
