Mathc initiation/a296
Installer ce fichier dans votre répertoire de travail.
kg_r.h |
---|
/* --------------------------------- */
/* save as kg_r.h */
/* --------------------------------- */
void G_r(
CTRL_splot w,
double ax,
double bx,
pt2d d,
double step,
double (*P_v)(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"
" \"a_r\" with line lt 9 lw 2,\\\n"
" \"dxdy\" with line lt 9 lw 2,\\\n"
" \"vx\" 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, 0.0);
fprintf(fp," %0.6f %0.6f \n", bx, ((*P_v)(bx)));
fprintf(fp," %0.6f %0.6f \n", bx, 0.0);
fclose(fp);
fp = fopen("a_r", "w");
t = ((ax+bx)/2.);
fprintf(fp," %0.6f %0.6f\n", t-(d.x), (*P_v)(t));
fprintf(fp," %0.6f %0.6f\n", t-(d.x), 0.0);
fprintf(fp," %0.6f %0.6f\n", t+(d.x), 0.0);
fprintf(fp," %0.6f %0.6f\n", t+(d.x), (*P_v)(t));
fprintf(fp," %0.6f %0.6f\n", t-(d.x), (*P_v)(t));
fclose(fp);
fp = fopen("dxdy", "w");
t = ((ax+bx)/2.);
fprintf(fp," %0.6f %0.6f\n", t-(d.x), (*P_v)(t/2) );
fprintf(fp," %0.6f %0.6f\n", t-(d.x), (*P_v)(t/2-3*d.y));
fprintf(fp," %0.6f %0.6f\n", t+(d.x), (*P_v)(t/2-3*d.y));
fprintf(fp," %0.6f %0.6f\n", t+(d.x), (*P_v)(t/2) );
fprintf(fp," %0.6f %0.6f\n", t-(d.x), (*P_v)(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);
printf(" ... load \"a_main.plt\" ... with gnuplot.\n\n");
}
/* --------------------------------- */
/* --------------------------------- */