public class Point3D {

    public float x, y, z;           // coordinate of vertex
	public boolean wgt0;			// tells whether w>0



    public Point3D() {
    }



    public Point3D(float xval, float yval, float zval) {
        x = xval;
        y = yval;
        z = zval;
		wgt0 = true;
    }


	
	public Point3D(Point3D copy) {
		x = copy.x;
		y = copy.y;
		z = copy.z;
		wgt0 = copy.wgt0;
	};



	public void copy(Point3D copy) {
		x = copy.x;
		y = copy.y;
		z = copy.z;
		wgt0 = copy.wgt0;
	};



    public String toString() {
        return new String(" ["+x+", "+y+", "+z+(wgt0?"]":" (w<=0) ]"));
    }



	public Point3D translate(Vector3 v)
	{
		return new Point3D(x+v.x, y+v.y, z+v.z);
	};
	
	
	
	public Point3D translate(Vector3 v, float frac)
	{
		return new Point3D(x+v.x*frac, y+v.y*frac, z+v.z*frac);
	};



	//This function returns a Point3D 'frac' of the way from 'this' to 'to'.
	public Point3D interpolate(Point3D to, float frac)
	{
		float newx = x + (to.x-x)*frac;
		float newy = y + (to.y-y)*frac;
		float newz = z + (to.z-z)*frac;
		return new Point3D(newx, newy, newz);
	};

	public Point3D interpolateToX(Point3D to, float newx)
	{
		return interpolate(to, (x-newx)/(x-to.x));
	};

	public Point3D interpolateToY(Point3D to, float newy)
	{
		return interpolate(to, (y-newy)/(y-to.y));
	};

	public Point3D interpolateToZ(Point3D to, float newz)
	{
		return interpolate(to, (z-newz)/(z-to.z));
	};



}