Aller au contenu

Mathc initiation/a225

Un livre de Wikilivres.


Sommaire


Installer ce fichier dans votre répertoire de travail.

kg_c.h
/* --------------------------------- */
/* save as kg_c.h                    */
/* --------------------------------- */
void G_Curve_2d(
CTRL_splot p,
double (*P_f)(double t),
double (*P_g)(double t),
tvalue t
)
{
FILE *fp = fopen("a_main.plt","w");

  fprintf(fp," reset\n"
             " set size ratio -1\n"
             " set zeroaxis lt 8\n" 
             " set grid\n\n" 
             " plot [%0.3f:%0.3f] [%0.3f:%0.3f]\\\n"
             " \"ab\"     with lines lt 7 lw 3 dt 3,\\\n"
             " \"length\" with lines lt 7 lw 3\n" ,
               p.xmin,p.xmax,p.ymin,p.ymax);
  fclose(fp);
    
  fp = fopen("length","w");
  for(t.value=t.min; t.value<t.max; t.value+=t.step)
      fprintf(fp," %6.3f  %6.3f\n",    (*P_f)(t.value),(*P_g)(t.value));
      
  fprintf(fp," %6.3f  %6.3f\n",        (*P_f)(t.max),  (*P_g)(t.max));
  fclose(fp);

  fp = fopen("ab","w");  
  fprintf(fp," %6.3f    0.   \n", (*P_f)(t.min)); 
  fprintf(fp," %6.3f %6.3f \n\n",(*P_f)(t.min),(*P_g)(t.min));

  fprintf(fp," %6.3f    0.   \n", (*P_f)(t.max)); 
  fprintf(fp," %6.3f %6.3f \n\n",(*P_f)(t.max),(*P_g)(t.max));
  fclose(fp);
}
/* --------------------------------- */
/* --------------------------------- */