Aller au contenu

Mathc gnuplot/Fichiers h : xfx x

Un livre de Wikilivres.


Installer ce fichier dans votre répertoire de travail.

y_o.h
/* ------------------------------------ */
/*      Save as : y_o.h                 */
/* ------------------------------------ */
void PD(
double **A
)
{
FILE * fp = fopen("data.plt","a");
       
fprintf(fp,"  %+.3f  %+.3f \n",
           A[R1][C1],A[R2][C1]);
 fclose(fp);
}
/* ------------------------------------ */
void PU(
double **A
)
{
FILE *fp = fopen("data.plt","a");
       
fprintf(fp,"\n  %+.3f  %+.3f \n",
           A[R1][C1],A[R2][C1]);
 fclose(fp);
}
/* ------------------------------------ */
double **Ginit(
double **U,
double xmin,
double xmax,
double ymin,
double ymax
)
{
FILE *fp;

        fp = fopen("a_main.plt","w");
fprintf(fp,"# Gnuplot file : load \"a_main.plt\" \n"
           "reset\n" 
           "set zeroaxis\n" 
           "set size ratio -1\n" 
           "plot [%0.3f:%0.3f] [%0.3f:%0.3f] \\\n"
           "\"data.plt\" with linesp pt 0\n"
           ,xmin,xmax,ymin,ymax);
 fclose(fp);

        fp = fopen("data.plt","w");
 fclose(fp);

        U[R0][C1] = 0.;/* angle */
        U[R1][C1] = 0.;/* x     */
        U[R2][C1] = 0.;/* y     */

        PD(U);

return(U);
}
/* ------------------------------------ */
double **GINIT(
double xmin,
double xmax,
double ymin,
double ymax
)
{
return( Ginit(I_mR(R2,C1),xmin,xmax,ymin,ymax) );
}
/* ------------------------------------ */
void SET(
double **U,
double angle,
double x,
double y
)
{
   U[R0][C1] = angle;
   U[R1][C1] = x;
   U[R2][C1] = y;

   PD(U);
}
/* ------------------------------------ */
void SETUP(
double **U,
double angle,
double x,
double y
)
{
   U[R0][C1] = angle;
   U[R1][C1] = x;
   U[R2][C1] = y;

   PU(U);
}
/* ------------------------------------ */
void GO(
double **U,
double Step
)
{
double **T = I_mR(R2,C2);
double **B = I_mR(R2,C1);
double **C = I_mR(R2,C1);

double angle=U[R0][C1];

   B[R1][C1] = 0.;
   B[R2][C1] = Step;

   rot2D_mR(T,PI/180.*(-angle));
   mul_mR(T,B,C);
   c_mR(U,B);
   add_mR(B,C,U);

   PD(U);

F_mR(C);
F_mR(B);
F_mR(T);
}
/* ------------------------------------ */
void GU(
double **U,
double Step
)
{
double **T = I_mR(R2,C2);
double **B = I_mR(R2,C1);
double **C = I_mR(R2,C1);

double angle=U[R0][C1];

   B[R1][C1] = 0.;
   B[R2][C1] = Step;

   rot2D_mR(T,PI/180.*(-angle));
   mul_mR(T,B,C);
   c_mR(U,B);
   add_mR(B,C,U);

   PU(U);

F_mR(C);
F_mR(B);
F_mR(T);
}
/* ------------------------------------ */
void TU(
double **U,
double angle
)
{
  U[R0][C1]+=angle;
}
/* ------------------------------------ */
/* ------------------------------------ */