/* dynamique.c
 Calcul de trajectoire par la 
 méthode de Newton
 ecrit le xx/xx/200x
 par yyyy et zzzz
 groupe : 
*/


#include <stdio.h>
#include <math.h>
#include <stdlib.h>

#define g 9.81
#define mu 1.12
#define GM 2250.

void nouvelle_position(double *xn, double *yn, double x,double y, double vx, double vy, double dt) {
  *xn = x + vx*dt;
  *yn = y + vy*dt;
}

 
int main (void) {
  double alpha;
  double x,y,x0,v0,vx,vy,t,dt;
  double x_new,y_new,vx_new,vy_new;
  double masse;
  char nom_fichier[100]="trajectoire.txt";
  FILE *fichier;
  
  /* Initialisation */
  x0 = -10.;
  x=x0;
  t = 0.;
  dt = 0.05;
  v0 = 15.;

  printf("angle alpha (en degrés) ?\n");
  scanf("%lf",&alpha);
  alpha = alpha*M_PI/180.;
  vx = v0 * cos(alpha);
  vy = v0 * sin(alpha);
  printf("ordonnée y ?\n");
  scanf("%lf",&y);
  printf("masse ?\n");
  scanf("%lf",&masse);
  
  
  fichier=fopen(nom_fichier,"w");  
  if (fichier == NULL) /* si echec ... */
        {
        printf("Impossible d'ouvrir %s en mode écriture\n",nom_fichier);
        exit(1);
        }


/* a completer */

				{
        fprintf(fichier," %lf  %lf\n",x,y);


        nouvelle_position(&x_new,&y_new,x,y,vx,vy,dt);
        x = x_new;
        y = y_new;
        t = t + dt;
				}

    

  printf("temps final = %lf s\n",t);

  return 0;
}
