public double angVetor(Vetor2d _ang) { double ang; ang = (x * _ang.getVetorX() + y * _ang.getVetorY()) / ((Math.Sqrt(x * x + _ang.getVetorY() * _ang.getVetorY()) * (Math.Sqrt(y * y + _ang.getVetorX() * _ang.getVetorX())))); return(ang); }
public double prodEscalar(Vetor2d prod) { double escalar; escalar = x * prod.getVetorX() + y * prod.getVetorY(); return(escalar); }
public Vetor2d projVetor(Vetor2d _proj) { Vetor2d z = new Vetor2d(); double aux = prodEscalar(_proj) / (Math.Pow(modVetor(), 2)); z.setVetorX(x * aux); z.setVetorY(y * aux); return(z); }
static void Main(string[] args) { Vetor2d vetor1 = new Vetor2d(1.0, 3.0); Vetor2d vetor2 = new Vetor2d(2.0, 4.0); double _prodEscalar = vetor1.prodEscalar(vetor2); double _modulo1 = vetor1.modVetor(); double _modulo2 = vetor2.modVetor(); double _angulo = vetor1.angVetor(vetor2); Vetor2d z = vetor1.projVetor(vetor2); Console.Write("Produto Escalar: "); Console.Write(_prodEscalar); Console.Write("\nModulo Vetor1: "); Console.Write(_modulo1); Console.Write("\nModulo Vetor2: "); Console.Write(_modulo2); Console.Write("\nO Angulo entre os Vetores 1 e 2: "); Console.Write(_angulo); Console.Write("\nProjecao entre os vetores 1 e 2: "); Console.Write(z.getVetorX()); Console.Write(","); Console.Write(z.getVetorY()); }