Mathc gnuplot/Application : Plan tangent

Un livre de Wikilivres.
Sauter à la navigation Sauter à la recherche
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 :

Conclusion

Annexe

Livre d'or



Préambule[modifier | modifier le wikicode]

Présentation[modifier | modifier le wikicode]

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

Dessiner le plan tangent au point P[modifier | modifier le wikicode]

Crystal Clear mimetype source c.png c01.c
Dessiner le plan tangent au point P
/* ------------------------------------ */
/*  Save as :   c01.c                   */
/* ------------------------------------ */
#include "x_ahfile.h"
#include       "fa.h"
/* ------------------------------------ */
int main(void)
{

 printf(" Draw the Tangent plane.\n\n"
        " f : (x,y)-> %s\n\n", feq);

     G_3d_v( i_WsGnuplot(-4,4,-4,4,-1,2),
             i_VGnuplot( 80.,38.,1.,1.),
             feq,f,f_z,
             i_point2d(2,0.));

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

 return 0;
}

Le résultat.

Résultat dans gnuplot
Tangente35


Les fichiers h de ce chapitre[modifier | modifier le wikicode]

Crystal Clear mimetype source h.png 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     "xspv.h"
#include     "xplt.h"
#include  "xfxy_x.h"
#include  "xfxyz_x.h"
/* ------------------------------------ */
#include    "kg_3d.h"


Crystal Clear mimetype source h.png fa.h
La fonction à dessiner
/* ------------------------------------ */
/*  Save as :   fa.h                    */
/* ------------------------------------ */
double f(
double x,
double y)
{
 return(       cos(x)+cos(y) );
}
char  feq[] = "cos(x)+cos(y)";
/* ------------------------------------ */
double f_z(
double x,
double y,
double z)
{
 return(         cos(x)+cos(y)-z );
}
char  f_zeq[] = "cos(x)+cos(y)-z";


Crystal Clear mimetype source h.png fa.h
La fonction graphique
/* ------------------------------------ */
/*  Save as :   kg_3d.h                 */
/* ------------------------------------ */
void G_3d_v(
  Ws_Ctrl W,
View_Ctrl V,
  char feq[],
double (*P_f) (double x, double y),
double (*P_fz)(double x, double y, double z),
point2d p
)
{
FILE      *fp;
point3d   P3D = i_point3d(p.x,p.y,(*P_f)(p.x,p.y));
double radius = .5;

        fp = fopen("a_main.plt","w");
fprintf(fp,"reset\n"
           "set size ratio -1\n"
           "set    samples 40\n"
           "set isosamples 40\n"
           "set hidden3d\n"
           "set view %0.3f, %0.3f, %0.3f, %0.3f \n"
           "splot[%0.3f:%0.3f][%0.3f:%0.3f][%0.3f:%0.3f]\\\n"
           " \"a_ka.plt\" with linesp lt 1 lw 4,\\\n"
           " \"a_kb.plt\" with linesp lt 1 lw 4 ps 2,\\\n"
           "%s lt 3",
            V.rot_x,V.rot_z,V.scale,V.scale_z,
            W.xmini,W.xmaxi,W.ymini,W.ymaxi,W.zmini,W.zmaxi,
            feq);
 fclose(fp);

 fp = fopen("a_ka.plt","w");
         fprintf(fp," %6.3f   %6.3f   %6.3f\n",
              p.x, p.y, (*P_f)(p.x,p.y) );
         fprintf(fp," %6.3f   %6.3f   %6.3f\n",
              p.x-fxyz_x((*P_fz),0.0001,P3D),
              p.y-fxyz_y((*P_fz),0.0001,P3D),
((*P_f)(p.x,p.y))-fxyz_z((*P_fz),0.0001,P3D));
 fclose(fp);

 fp = fopen("a_kb.plt","w");
         fprintf(fp," %6.3f   %6.3f   %6.3f\n",
              p.x+radius,
              p.y+radius,
              fxy_x((*P_f),0.0001,p)*(+radius)+
              fxy_y((*P_f),0.0001,p)*(+radius)+
              (*P_f)(p.x,p.y)
              );
         fprintf(fp," %6.3f   %6.3f   %6.3f\n",
              p.x-radius,
              p.y+radius,
              fxy_x((*P_f),0.0001,p)*(-radius)+
              fxy_y((*P_f),0.0001,p)*(+radius)+
              (*P_f)(p.x,p.y)
              );
         fprintf(fp," %6.3f   %6.3f   %6.3f\n",
              p.x-radius,
              p.y-radius,
              fxy_x((*P_f),0.0001,p)*(-radius)+
              fxy_y((*P_f),0.0001,p)*(-radius)+
              (*P_f)(p.x,p.y)
              );
         fprintf(fp," %6.3f   %6.3f   %6.3f\n",
              p.x+radius,
              p.y-radius,
              fxy_x((*P_f),0.0001,p)*(+radius)+
              fxy_y((*P_f),0.0001,p)*(-radius)+
              (*P_f)(p.x,p.y)
              );
         fprintf(fp," %6.3f   %6.3f   %6.3f\n",
              p.x+radius,
              p.y+radius,
              fxy_x((*P_f),0.0001,p)*(+radius)+
              fxy_y((*P_f),0.0001,p)*(+radius)+
              (*P_f)(p.x,p.y)
              );
         fprintf(fp," %6.3f   %6.3f   %6.3f\n",
              p.x-radius,
              p.y-radius,
              fxy_x((*P_f),0.0001,p)*(-radius)+
              fxy_y((*P_f),0.0001,p)*(-radius)+
              (*P_f)(p.x,p.y)
              );
         fprintf(fp," %6.3f   %6.3f   %6.3f\n",
              p.x+radius,
              p.y-radius,
              fxy_x((*P_f),0.0001,p)*(+radius)+
              fxy_y((*P_f),0.0001,p)*(-radius)+
              (*P_f)(p.x,p.y)
              );
         fprintf(fp," %6.3f   %6.3f   %6.3f\n",
              p.x-radius,
              p.y+radius,
              fxy_x((*P_f),0.0001,p)*(-radius)+
              fxy_y((*P_f),0.0001,p)*(+radius)+
              (*P_f)(p.x,p.y)
              );
 fclose(fp);

 Pause();
}