//[Update:[Wed Jul 22 IST 2020]]
/*History:
**Thu Oct 24 2019
   Started.
**Wed Oct 30 2019
 First working version.
*/

public class Vec3  {
    double x,y,z;
    
    public Vec3(double x, double y, double z) {
        this.x = x;
        this.y = y;
        this.z = z;
    }

    public Vec3 times(double mult) {
        return new Vec3(mult*x, mult*y, mult*z);
    }
    
    public Vec3 plus(Vec3 other) {
        return new Vec3(x+other.x, y+other.y, z+other.z);
    }

    public Vec3 minus(Vec3 other) {
        return new Vec3(x-other.x, y-other.y, z-other.z);
    }

    public Vec3 scale(double xs, double ys, double zs) {
        return new Vec3(xs*x, ys*y, zs*z);
    }

    public double normsq() {
        return x*x+y*y+z*z;
    }

    public double dot(Vec3 other) {
        return x*other.x + y*other.y + z*other.z;
    }

    public Vec3 cross(Vec3 other) {
        return new Vec3(
                        y*other.z - z*other.y,
                        z*other.x - x*other.z,
                        x*other.y - y*other.x
                        );
                        
    }
    public Vec2 proj() {
        if(z >= -1) throw new RuntimeException("Point too close to camera!"+this);
        return new Vec2(-x/z,-y/z);
    }
    
    public String toString() {
        return "["+x+", "+y+", "+z+"]";
    }
    
    public static void main(String args[]) {

  
    }
}
