Aller au contenu

Mathc initiation/a37

Un livre de Wikilivres.


Sommaire


Installer ce fichier dans votre répertoire de travail.


kg_shelg.h
/* ---------------------------------- */
/* save as kg_shelg.h                 */
/* ---------------------------------- */
void   G_SolidRevolCylindShellfg(
double xmin,
double xmax,
double ymin,
double ymax,
double a,
double b,
double dx,
double step,
double (*P_f)(double x),
double (*P_g)(double x)
)
{
FILE   *fp;
char    F_ar[FILENAME_MAX] = "a_ar";
char    F_br[FILENAME_MAX] = "a_br";
char    F_al[FILENAME_MAX] = "a_al";
char    F_bl[FILENAME_MAX] = "a_bl";
char    F_fr[FILENAME_MAX] = "a_fr";
char    F_gr[FILENAME_MAX] = "a_gr";
char    F_fl[FILENAME_MAX] = "a_fl";
char    F_gl[FILENAME_MAX] = "a_gl";
char    F_xm[FILENAME_MAX] = "a_xm";
char    F_rect[FILENAME_MAX] = "a_rect";

double  t1;
double  t2;
double  i;

        fp = fopen("a_main.plt","w");
fprintf(fp," set zeroaxis lt 8\n");
fprintf(fp," set grid\n\n");

t1 = ((a+b)/2.);
t2 = ((*P_f)((a+b)/2.)) + 2. * dx;
fprintf(fp," set label \"dx\" at %0.3f, %0.3f\n\n", t1, t2);

t1 = ((a+b)/2.);
t2 = ((*P_g)((a+b)/2.)) - 2. * dx;
fprintf(fp," set label \"average radius\" at %0.3f, %0.3f \n\n", t1, t2);

t1 = ((a+b)/2.)+2*dx;
t2 = (((*P_f)((a+b)/2.)) + ((*P_g)((a+b)/2.))) / 2.;
fprintf(fp," set label \"altitude : f-g\" at %0.3f, %0.3f \n\n", t1, t2);

fprintf(fp," plot [%0.3f:%0.3f] [%0.3f:%0.3f] ",xmin,xmax,ymin,ymax);

fprintf(fp," \"%s\" with linesp lt 3 pt 0,\\\n",F_ar);
fprintf(fp," \"%s\" with linesp lt 3 pt 0,\\\n",F_br);
fprintf(fp," \"%s\" with linesp lt 3 pt 0,\\\n",F_al);
fprintf(fp," \"%s\" with linesp lt 3 pt 0,\\\n",F_bl);
fprintf(fp," \"%s\" with linesp lt 3 pt 0,\\\n",F_fr);
fprintf(fp," \"%s\" with linesp lt 3 pt 0,\\\n",F_gr);
fprintf(fp," \"%s\" with linesp lt 3 pt 0,\\\n",F_fl);
fprintf(fp," \"%s\" with linesp lt 3 pt 0,\\\n",F_gl);
fprintf(fp," \"%s\" with linesp lt 9 pt 0,\\\n",F_rect);
fprintf(fp," \"%s\" with linesp lt 7 pt 7\n\n" ,F_xm);
fprintf(fp," reset");
             fclose(fp);


        fp = fopen(F_ar,  "w");
fprintf(fp," %0.6f   %0.6f\n", a,  ((*P_f)(a)));
fprintf(fp," %0.6f   %0.6f\n", a,  ((*P_g)(a)));
             fclose(fp);


        fp = fopen(F_br,  "w");
fprintf(fp," %0.6f   %0.6f\n", b,  ((*P_f)(b)));
fprintf(fp," %0.6f   %0.6f\n", b,  ((*P_g)(b)));
             fclose(fp);


        fp = fopen(F_al,  "w");
fprintf(fp," %0.6f   %0.6f\n", -a,  ((*P_f)(a)));
fprintf(fp," %0.6f   %0.6f\n", -a,  ((*P_g)(a)));
             fclose(fp);


        fp = fopen(F_bl,  "w");
fprintf(fp," %0.6f   %0.6f\n",-b,  ((*P_f)(b)));
fprintf(fp," %0.6f   %0.6f\n",-b,  ((*P_g)(b)));
             fclose(fp);


        fp = fopen(F_rect,  "w");
t1 = (a+b)/2.- (dx);
t2 = (*P_f)( (a+b)/2.) ;
fprintf(fp," %0.6f   %0.6f\n", t1,   t2);

t1 = (a+b)/2.- (dx) ;
t2 = (*P_g)( (a+b)/2.) ;
fprintf(fp," %0.6f   %0.6f\n", t1,   t2);

t1 = (a+b)/2.+ (dx) ;
t2 = (*P_g)( (a+b)/2.) ;
fprintf(fp," %0.6f   %0.6f\n", t1,   t2);

t1 = (a+b)/2.+ (dx);
t2 = (*P_f)( (a+b)/2.) ;
fprintf(fp," %0.6f   %0.6f\n", t1,   t2);

t1 = (a+b)/2.- (dx);
t2 = (*P_f)( (a+b)/2.) ;
fprintf(fp," %0.6f   %0.6f\n", t1,   t2);
             fclose(fp);


        fp = fopen(F_fr,  "w");
i = a;
do{
   fprintf(fp," %0.6f   %0.6f\n", i, ((*P_f)(i)));
   i += step;
}while(i <=  b);
             fclose(fp);


        fp = fopen(F_gr,  "w");
i = a;
do{
   fprintf(fp," %0.6f   %0.6f\n", i, ((*P_g)(i)));
   i += step;
}while(i <=  b);
             fclose(fp);


        fp = fopen(F_fl,  "w");
i = a;
do{
   fprintf(fp," %0.6f   %0.6f\n", -i, ((*P_f)(i)));
   i += step;
}while(i <=  b);
             fclose(fp);


        fp = fopen(F_gl,  "w");
i = a;
do{
   fprintf(fp," %0.6f   %0.6f\n", -i, ((*P_g)(i)));
   i += step;
}while(i <=  b);
             fclose(fp);


         fp = fopen(F_xm,  "w");
t1 = ((a+b)/2.);        
t2 = ((*P_g)((a+b)/2.)) ;
fprintf(fp," %0.6f   %0.6f\n", t1,  t2);
             fclose(fp);
}
/* ---------------------------------- */
/* ---------------------------------- */


Déclaration des fichiers h.