package ruum;

public class Vektor extends Punkt{

public Vektor(){super();}
public Vektor(int x, int y, int z){
this.x=x; this.y=y; this.z=z;
}

public double pikkus(){
return Math.sqrt(x*x+y*y+z*z);
}

public static double pikkus(Koht3d p){
return Math.sqrt(p.x*p.x+p.y*p.y+p.z*p.z);
}

public int skalaarkorruta(Vektor v2){
return x*v2.x+y*v2.y+z*v2.z;
}

public static int skalaarkorruta(Vektor v1, Vektor v2){
return v1.x*v2.x+v1.y*v2.y+v1.z*v2.z;
}

public Vektor vektorkorruta(Vektor v2){
 Vektor v=new Vektor();
 v.x=y*v2.z-z*v2.y;
 v.y=v2.x*z-x*v2.z;
 v.z=x*v2.y-y*v2.x;
 return v;
}

public static Vektor vektorkorruta(Vektor v1, Vektor v2){
 Vektor v=new Vektor();
 v.x=v1.y*v2.z-v1.z*v2.y;
 v.y=v2.x*v1.z-v1.x*v2.z;
 v.z=v1.x*v2.y-v1.y*v2.x;
 return v;
}

public Vektor normaalvektor(Vektor v2){
 long lx, ly, lz;
 Vektor v=new Vektor();
 lx=(long)y*v2.z-z*v2.y;
 ly=(long)v2.x*z-x*v2.z;
 lz=(long)x*v2.y-y*v2.x;
 while((lx>Integer.MAX_VALUE)|(ly>Integer.MAX_VALUE)|(lz>Integer.MAX_VALUE))
 {lx/=2; ly/=2; lz/=2;}
 v.x=(int)lx; v.y=(int)ly; v.z=(int)lz;
 return v;
}

public static Vektor normaalvektor(Vektor v1, Vektor v2){
 long lx, ly, lz;
 Vektor v=new Vektor();
 lx=(long)v1.y*v2.z-v1.z*v2.y;
 ly=(long)v2.x*v1.z-v1.x*v2.z;
 lz=(long)v1.x*v2.y-v1.y*v2.x;
 while((lx>Integer.MAX_VALUE)|(ly>Integer.MAX_VALUE)|(lz>Integer.MAX_VALUE))
 {lx/=10; ly/=10; lz/=10;}
 v.x=(int)lx; v.y=(int)ly; v.z=(int)lz;
 return v;
}


}
