Mathc gnuplot/Application : Fonction vectorielle 3D

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

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


Préambule

modifier

Présentation

modifier

Dessiner

modifier
c01.c
Dessiner un vecteur tangent et normales unitaire.
/* ------------------------------------ */
/*  Save as :   c01.c                   */
/* ------------------------------------ */
#include "x_ahfile.h"
#include       "fa.h"
/* ------------------------------------ */
int main(void)
{
double t     =  4.;

 printf(" r(t) = f(t)i + g(t)j + h(t)k \n\n");
 printf(" With \n\n");
 printf(" f : t-> %s  \n", feq);
 printf(" g : t-> %s  \n", geq);
 printf(" h : t-> %s\n\n", heq);
 printf(" t = %+.2f \n\n",   t);

     G_Curve_3d(i_time(0.,6.*PI,.01),
                f,g,h,
                Tf,Tg,Th,
                t);

 printf(" Draw the velocity and accelerator vectors"
        " at the point P(f(t),g(t)),                \n\n"
        " open the file \"a_main.plt\" with Gnuplot.\n\n");

 printf("\n Press return to continue");
 getchar();

 return 0;
}

Le résultat.

Résultat dans gnuplot
Curve06
Résultat dans gnuplot
Curve07


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    "xfx_x.h"
/* ------------------------------------ */
#include   "knfx_x.h"
#include "kg_ctan1.h"


knfx_x.h
Normalisé
/* ------------------------------------ */
/*  Save as :   knfx_x.h                 */
/* ------------------------------------ */
double fx_x_Normalize(
double (*P_f)(double x),
double (*P_g)(double x),
double (*P_h)(double x),
double t,
double e
)
{
double Df=fx_x((*P_f),t,e);
double Dg=fx_x((*P_g),t,e);
double Dh=fx_x((*P_h),t,e);

 return(Df/sqrt(Df*Df+Dg*Dg+Dh*Dh));
}


fa.h
La fonction à dessiner
/* ------------------------------------ */
/*  Save as :   fa.h                    */
/* ------------------------------------ */
double f(
double t)
{
        return( cos(t));
}
char  feq[] =  "cos(t)";
/* ------------------------------------ */
double g(
double t)
{
        return( sin(t));
}
char  geq[] =  "sin(t)";
/* ------------------------------------ */
double h(
double t)
{
        return( t);
}
char  heq[] =  "t";
/* ------------------------------------ */
double Tf(
double t)
{
        return(
        -(sin(t)/sqrt(2))
        );
}
/* ------------------------------------ */
double Tg(
double t)
{
        return(
        cos(t)/sqrt(2)
        );
}
/* ------------------------------------ */
double Th(
double t)
{
        return(
        1/sqrt(2)
        );
}


kg_ctan1.h
La fonction graphique
/* ------------------------------------ */
/*  Save as :   kg_ctan1.h              */
/* ------------------------------------ */
void G_Curve_3d(
t_Ctrl T,
double (*P_f)(double t),
double (*P_g)(double t),
double (*P_h)(double t),
double (*P_Tf)(double t),
double (*P_Tg)(double t),
double (*P_Th)(double t),
double t
)
{
FILE *fp;
double i;
double e = .001;

fp = fopen("a_main.plt","w");
fprintf(fp," reset\n"
           " set zeroaxis lt 8\n"
           " set grid\n\n"
           " splot \\\n"
           " \"a_curve.plt\" with line lt 3,\\\n"
           " \"a_radius.plt\" with line lt 2,\\\n"
           " \"atangent.plt\" with line lt 4,\\\n"
           " \"anormal.plt\" with line lt 1 ");
fclose(fp);

        fp = fopen("a_curve.plt","w");
for(i=T.mini; i<=T.maxi; i+=T.step)
fprintf(fp," %6.3f  %6.3f  %6.3f\n",
       (*P_f)(i),
       (*P_g)(i),
       (*P_h)(i));
 fclose(fp);

        fp = fopen("a_radius.plt","w");
fprintf(fp,"  0  0  0   \n %6.5f  %6.5f  %6.5f  \n",
       (*P_f)(t),
       (*P_g)(t),
       (*P_h)(t));
 fclose(fp);

        fp = fopen("atangent.plt","w");
fprintf(fp,"  %6.5f  %6.5f  %6.5f \n"
           "  %6.5f  %6.5f  %6.5f \n",
       (*P_f)(t),
       (*P_g)(t),
       (*P_h)(t),
       (*P_f)(t)+fx_x_Normalize((*P_f),(*P_g),(*P_h),t,e),
       (*P_g)(t)+fx_x_Normalize((*P_g),(*P_f),(*P_h),t,e),
       (*P_h)(t)+fx_x_Normalize((*P_h),(*P_f),(*P_g),t,e) );
 fclose(fp);

        fp = fopen("anormal.plt","w");
fprintf(fp,"  %6.5f  %6.5f  %6.5f \n"
           "  %6.5f  %6.5f  %6.5f \n",
       (*P_f)(t),
       (*P_g)(t),
       (*P_h)(t),
       (*P_f)(t)+fx_x_Normalize((*P_Tf),(*P_Tg),(*P_Th),t,e),
       (*P_g)(t)+fx_x_Normalize((*P_Tg),(*P_Tf),(*P_Th),t,e),
       (*P_h)(t)+fx_x_Normalize((*P_Th),(*P_Tf),(*P_Tg),t,e));
 fclose(fp);

 Pause();
}

Algorithme

modifier
r(t) = f(t) i + g(t) j + h(t) k
T(t) = r'(t) / ||r'(t)||
N(t) = T'(t) / ||T'(t)||