Aller au contenu

Mathc initiation/a298

Un livre de Wikilivres.


Sommaire


Installer ce fichier dans votre répertoire de travail.


kg_dxdy.h
/* --------------------------------- */
/* save as kg_dxdy.h                 */
/* --------------------------------- */
void   G_dxdy(
CTRL_splot w,
double ax,
double bx,
pt2d    d,
double step,
double (*P_v)(double x),
double (*P_u)(double x)
)
{
double  t;
double  i;

FILE   *fp = fopen("a_main.plt","w");

 fprintf(fp," set zeroaxis lt 8\n" 
            " set grid\n\n" 
            " plot [%0.3f:%0.3f] [%0.3f:%0.3f]\\\n"
            " \"ab\"    with line lt 7 lw 2,\\\n" 
            " \"dxdy\"  with line lt 9 lw 2,\\\n" 
            " \"vx\"    with line lt 7 lw 2,\\\n" 
            " \"ux\"    with line lt 7 lw 2   \n"            
            " reset\n\n",
              w.xmin,w.xmax,w.ymin,w.ymax);
  fclose(fp);

 fp = fopen("ab",  "w");
 fprintf(fp," %0.6f   %0.6f  \n", ax, ((*P_v)(ax)));
 fprintf(fp," %0.6f   %0.6f\n\n", ax, ((*P_u)(ax))); 
 fprintf(fp," %0.6f   %0.6f  \n", bx, ((*P_v)(bx)));
 fprintf(fp," %0.6f   %0.6f  \n", bx, ((*P_u)(bx)));
  fclose(fp);

        fp = fopen("dxdy",  "w");
   t = ((ax+bx)/2.);
fprintf(fp," %0.6f   %0.6f\n", t-(d.x), ((*P_v)(t)+(*P_u)(t))/2.      );
fprintf(fp," %0.6f   %0.6f\n", t-(d.x), ((*P_v)(t)+(*P_u)(t))/2.-3*d.y);
fprintf(fp," %0.6f   %0.6f\n", t+(d.x), ((*P_v)(t)+(*P_u)(t))/2.-3*d.y);
fprintf(fp," %0.6f   %0.6f\n", t+(d.x), ((*P_v)(t)+(*P_u)(t))/2.      );
fprintf(fp," %0.6f   %0.6f\n", t-(d.x), ((*P_v)(t)+(*P_u)(t))/2.      );
             fclose(fp);

 fp = fopen("vx",  "w");
  i = ax;
  do{
     fprintf(fp," %0.6f   %0.6f\n", i, ((*P_v)(i)));
     i += step;
     }while(i <=  bx);
  fclose(fp);

 fp = fopen("ux",  "w");
  i = ax;
  do{
     fprintf(fp," %0.6f   %0.6f\n", i, ((*P_u)(i)));
     i += step;
     }while(i <=  bx);
  fclose(fp);
             
  printf(" ... load \"a_main.plt\" ... with gnuplot.\n\n");             
}
/* --------------------------------- */
/* --------------------------------- */


Déclaration des fichiers h.