/* balistique.c
   auteurs :
   groupe : 
   date :
*/
#include <stdio.h>
#include <math.h>
#define g 9.81


void position(/* compléter ... */) {
  /* compléter ... */
}

int main (void) {
  double x0,y0,v0;
  double alpha,pi=3.14159;
  double x,y,t,dt;
  char nom_fichier[100]="trajectoire.txt";
  FILE *fichier;
  double tlim,tmax,delta;
  double portee,altitude;
  
  /* Initialisation */
  x0 = -10.;
  t = 0.;
  dt = 0.05;
  v0 = 15.;
  
  printf("angle alpha (en degrés) ?\n");
  scanf("%lf",&alpha);
  alpha = alpha*pi/180.;
  printf("ordonnée y ?\n");
  scanf("%lf",&y0);
  
  /* essai d'ouverture de fichier en mode ecriture */
  fichier=fopen(nom_fichier,"w"); 
  if (fichier == NULL)
    {
    printf("Impossible d'ouvrir %s en mode écriture\n",nom_fichier);
    exit(1);
    }

  x = x0;
  y = y0;
  while (y>=0)
    {
    position(/* compléter ... */);
    fprintf(fp," %8.4f  %8.4f\n",x,y);

    t = t + dt;
    } 

  tmax = v0*sin(alpha)/g;
  delta=v0*v0*sin(alpha)*sin(alpha) + 2*g*y0;
  tlim = (v0*sin(alpha) + sqrt(delta)) /g;
  position(tmax,/* compléter ... */);
  position(tlim,/* compléter ... */);
  portee = portee - x0;
  printf("portee = %f\naltitude max. = %f\n",portee,altitude);
  
  return 0;
}
