Mostrando entradas con la etiqueta magnitud. Mostrar todas las entradas
Mostrando entradas con la etiqueta magnitud. Mostrar todas las entradas

domingo, 15 de marzo de 2009

operaciones con vectores

public class Main {


public static void main(String[] args) {
// TODO code application logic here
double []v;
double []w;
double []z;

v=new double [3];
w=new double [3];
z=new double [3];

double product_escalar = 0;
double magnitud = 0;
double resulma =0;
double unitario = 0;
double angulo = 0;
double magnitud1=0;
double producto=0;

v[0]=1 ;v[1]=6; v[2]=4;
w[0]=5 ;w[1]=-2;w[2]=3;

//suma v[i]+w[i]

for(int i=0; i<3 ;i++)
z[i]= w[i]+v[i];

for(int i=0; i<3 ;i++)
System.out.println("EL RESULTADO DE LA SUMA ES: "+z[i]+", ");


// resta v[i]-[i]

for(int i=0; i<3 ;i++)
z[i]= w[i]-v[i];

for(int i=0; i<3 ;i++)
System.out.println("EL RESULTADO DE LA RESTA ES: " + z[i] +" ");

// producto escalar v[i]*[i]

for(int i=0; i<3 ;i++)
product_escalar += w[i]*v[i];

System.out.println("EL RESULTADO DE LA PRODUCTO ESCALAR ES: " +product_escalar);


// magnitud

resulma+=(magnitud= Math.sqrt(Math.pow(w[0],2)+Math.pow(w[1],2)+Math.pow(w[2],2))+(magnitud1= Math.sqrt(Math.pow(v[0],2)+Math.pow(v[1],2)+Math.pow(v[2],2))));

System.out.println("EL RESULTADO DE LA MAGNITUD ES "+resulma);


// unitario
for(int i=0; i<3 ;i++)
unitario += (w[i]+v[i])/resulma;

for(int i=0; i<3 ;i++)
System.out.println("EL RESULTADO DEL UNITARIO ES: " +unitario);

// angulo entre w y v

for(int i=0; i<3 ;i++)
angulo = Math.acos(product_escalar/(magnitud*magnitud1));

for(int i=0; i<3 ;i++)

System.out.println("EL RESULTADO DEL ANGULO ES: " +angulo);

//producto cruz
producto+= (((v[1]*w[2])-(v[2]*w[1]))+((v[0]*w[2])-(v[2]*w[0]))+((v[0]*w[2])-(v[2]*w[0])));

System.out.println("El valor cruz es: " +producto);


}

}