class prbProyectil { /* Redondea o más bien limita a un número decimal a tener un decimal. */ public static double redondear(double num) { double aux = num * 10; int tmp = (int) aux; return (double) tmp / 10; } /* Dado un proyectil, calcula con los métodos disponibles del objeto , el tiempo total de recorrido. */ public static double t_recorrido(Proyectil p) { p.velocidad.evaluar(0.0); double vel[ ] = p.velocidad.obtenerEvaluacion(); return 2 * vel[p.velocidad.Z] / p.G; } public static void main(String arg[ ]) { Proyectil p = new Proyectil( ); double arr_acel[ ] = { 0.0 , 0.0 , -9.8 }; p.asignarAceleraciones(arr_acel); double vel_ini[ ] = { 30.0 , 5.0 , 130.0 }; double pos_ini[ ] = { 2.0 , 1.0 , 0.0 }; p.calcularVectores(vel_ini , pos_ini); System.out.println("\n\ttiempo\t\tPosicion\t\t\tVelocidad"); System.out.println("\t------\t\t--------\t\t\t---------\n"); System.out.println("\tt\t\tPx\tPy\tPz\t\tvz\tV\tdif\n"); double t_total = t_recorrido(p); double interv = t_total / 14; double t = 0.0; while(t <= t_total) { double pos[ ], vel[ ]; vel = p.obtenerVelocidad(t); pos = p.obtenerPosicion(t); System.out.print("\t" + redondear(t) + "\t"); for(int k = 0; k < 3; k++) System.out.print("\t"+ redondear(pos[k])); System.out.print("\t\t" + redondear(vel[2])); double aux_norma = redondear(p.velocidad.norma( )); double aux_vz = redondear(vel[2]); double dif = Math.abs(aux_norma) - Math.abs(aux_vz); dif = Math.abs(dif); dif = redondear(dif); System.out.print("\t" + aux_norma); System.out.println("\t"+ dif ); t += interv; } System.out.println( ); } }