Mathc gnuplot/Animer deux points

Mathc gnuplot
Mathc gnuplot
Mathc gnuplot
Sommaire

I - Dessiner

Fichiers h partagés :

Application :

II - Animer

Application :

III - Géométrie de la tortue standard

Application :

IV - Géométrie de la tortue vectorielle

Application :

Annexe

Livre d'or



Préambule modifier

Créer une animation avec la commande "pause 1" de gnuplot. La position des deux points sont dans les fichiers a_p***

Présentation modifier

N'oubliez pas les fichiers *.h partagés et ceux de ce chapitre.

L'animation modifier

  c01.c
Créer une liste de commande.
/* ------------------------------------ */
/*  Save as :   c01.c                   */
/* ------------------------------------ */
#include "x_ahfile.h"
#include        "f.h"
/* ------------------------------------ */
int main(void)
{
    G_plt(i_WGnuplot(-5,5, -1,10),
          i_time(-3.,5., .01),
          feq,f);

 printf(" open the file \"a_main.plt\" with Gnuplot.\n\n"
        " Press return to continue\n");
 getchar();

 return 0;
}

Le résultat.

 # Gnuplot file : load "a_main.plt"

 reset
 plot[-4.000:6.000] [-1.000:10.000]\
 -0.5*x**2 + 1.0*x + 8.0 lt 13,\
 "a_paab"  pt 7 ps 3 

 reset
 plot[-4.000:6.000] [-1.000:10.000]\
 -0.5*x**2 + 1.0*x + 8.0 lt 13,\
 "a_paac"  pt 7 ps 3 

 reset
 plot[-4.000:6.000] [-1.000:10.000]\
 -0.5*x**2 + 1.0*x + 8.0 lt 13,\
 "a_paad"  pt 7 ps 3 

 reset
 plot[-4.000:6.000] [-1.000:10.000]\
 -0.5*x**2 + 1.0*x + 8.0 lt 13,\
 "a_paae"  pt 7 ps 3


Les fichiers h de ce chapitre modifier

  x_ahfile.h
Appel des fichiers
/* ------------------------------------ */
/*  Save as :   x_ahfile.h              */
/* ------------------------------------ */
#include    <stdio.h>
#include   <stdlib.h>
#include    <ctype.h>
#include     <time.h>
#include     <math.h>
#include   <string.h>
/* ------------------------------------ */
#include     "xdef.h"
#include     "xplt.h"
/* ------------------------------------ */
#include     "xg_f.h"


  f.h
La fonction à dessiner
/* ------------------------------------ */
/*  Save as :   f.h                     */
/* ------------------------------------ */
double f(
double x)
{
 return(       -0.5*x*x  + 1.0*x + 8.0);
}
char  feq[] = "-0.5*x**2 + 1.0*x + 8.0";


  xg_f.h
La fonction graphique
/* ------------------------------------ */
/*  Save as :   xg_f.h                  */
/* ------------------------------------ */
void  G_plt(
W_Ctrl w,
t_Ctrl Pic,
char feq[],
double (*P_f)(double x)
)
{
FILE   *fp1;
FILE   *fp2;
double  p,q;
char files[] = "a_paaa";

        fp1 = fopen("a_main.plt","w");
fprintf(fp1,"# Gnuplot file : load \"a_main.plt\" \n\n");

for(p=q=Pic.mini; p<Pic.maxi; p+=Pic.step)
{
 fprintf(fp1," reset\n"
             " pause %0.2f \n"
             " plot[%0.3f:%0.3f] [%0.3f:%0.3f]\\\n"
             " %s lt 13,\\\n"
             " \"%s\"  pt 7 ps 3 \n",
             Pic.step,w.xmini,w.xmaxi,w.ymini,w.ymaxi,
             feq,
             NewName(files));

         fp2 = fopen(files,"w");
 fprintf(fp2," %+0.6f %+0.6f\n",p,(*P_f)(p));
 fprintf(fp2," %+0.6f %+0.6f\n",q,(*P_f)(p));
 fclose(fp2);
}
 fclose(fp1);
}