Aller au contenu

Mathc initiation/a217

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 c,
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"
             " \"curve\"  with lines lt 7 lw 1,\\\n"
             " \"ab\"     with lines lt 7 lw 3 dt 2,\\\n"
             " \"length\" with lines lt 1 lw 3\n" ,
               p.xmin,p.xmax,p.ymin,p.ymax);
  fclose(fp);


  fp = fopen("curve","w");
  for(c.value=c.min; c.value<c.max; c.value+=c.step)
      fprintf(fp," %6.3f  %6.3f\n",    (*P_f)(c.value),(*P_g)(c.value));
      
  fprintf(fp," %6.3f  %6.3f\n",        (*P_f)(c.max),  (*P_g)(c.max)); 
  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\n",        (*P_f)(t.max),  (*P_g)(t.max)); 
  fclose(fp);


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