Mathc gnuplot/Application : Vecteur normal
Apparence
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 vecteur normale au point P
[modifier | modifier le wikicode]c01.c Dessiner le vecteur normale au point P |
---|
/* ------------------------------------ */
/* Save as : c01.c */
/* ------------------------------------ */
#include "x_ahfile.h"
#include "fa.h"
/* ------------------------------------ */
int main(void)
{
printf(" Draw the normal vector at the point P.\n\n"
" f : (x,y)-> %s\n\n", feq);
G_3d_v(i_WsGnuplot(-3,3,-3,3,-.5,2),
i_VGnuplot( 94.,22.,1.,1.),
feq,f,f_z,
i_point2d(1,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 |
---|
Les fichiers h de ce chapitre
[modifier | modifier le wikicode]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 "xspv.h"
#include "xfxyz_x.h"
/* ------------------------------------ */
#include "kg_3dv.h"
fa.h La fonction à dessiner |
---|
/* ------------------------------------ */
/* Save as : fa.h */
/* ------------------------------------ */
double f(
double x,
double y)
{
return( (2*exp(-x) * cos(y)) );
}
char feq[] = "2*exp(-x) * cos(y)";
/* ------------------------------------ */
double f_z(
double x,
double y,
double z)
{
return( (2*exp(-x) * cos(y) - z) );
}
char f_zeq[] = "2*exp(-x) * cos(y) - z";
kg_3dv.h La fonction graphique |
---|
/* ------------------------------------ */
/* Save as : kg_3dv.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));
fp = fopen("a_main.plt","w");
fprintf(fp,"reset\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 linespoints,\\\n"
"%s ",
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);
Pause();
}