Application


Installer et compiler ces fichiers c dans votre répertoire de travail.


Vous trouverez le code source et le fichier graphique correspondant à chaque transformation.

L'étude des matrices de transformation fait partie d'un cours de mathématiques et sort du cadre de ce livre.

cb01.c
/* ------------------------------------ */
/*  Save as :   cb01.c                  */
/* ------------------------------------ */
#include      "v_a.h"
#include  "d_strct.h"
#include "d_lastr1.h"
#include   "d_guv.h"
/* ------------------------------------ */
#define        N  (2*C5)
#define    ALPHA  (40.)
/* ------------------------------------ */
void fun(void)
{
double u[N] ={0,6,6,0,0,
              0,0,6,6,0};

double **U  =             ca_A_mR(u,i_mR(R2,C5));
double **V  =                       i_mR(R2,C5);
double **T  =     Rot2D_mR(eye_mR(  i_mR(R3,C3)),PI/180.*ALPHA);
double **Ut =   c_mR(U,lastr_1_mR(  i_mR(R3,C5)));
double **Vt =                       i_mR(R3,C5);

  clrscrn();
  printf("\n Rotation (%+.f degree) : \n", ALPHA);
  printf("\n                | cos(alpha)  -sin(alpha)   0 |    ");
  printf("\n           v  = | sin(alpha)   cos(alpha)   0 |  u ");
  printf("\n                |          0           0    1 |\n\n");

  printf(" T:");
  p_mR(T,S8,P2,C9);

  printf(" U:");
  p_mR(U,S8,P2,C9);


  printf(" V:");
  mul_mR(T,Ut,Vt);
  c_nr_mR(Vt,R2,V);
  p_mR(V,S8,P2,C9);

  G_uv_mR(i_WGnuplot(-20,20,-10,10),U,V);
  printf("  * open the file main.plt with Gnuplot. \n\n\n");
  stop();
  
  f_mR(U);
  f_mR(V);
  f_mR(T);
  f_mR(Ut);
  f_mR(Vt);
}
/* ------------------------------------ */
void hello(void)
{
  printf("\n\n\n                                              ");
  printf("\n          Rotation about the origin  :            ");
  printf("\n          *************************               ");
  printf("\n\n                                                ");
  printf("\n\n                                                ");
  printf("\n               | cos(alpha)  -sin(alpha)   0 |    ");
  printf("\n          v  = | sin(alpha)   cos(alpha)   0 |  u ");
  printf("\n               |          0           0    1 |\n\n");
  printf("\n\n                                                ");
  printf("\n\n                                                ");
  printf("                                          \n\n\n\n\n");
  stop();
}
/* ------------------------------------ */
int main(void)
{
  hello();
    fun();
    
  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
cb02.c
/* ------------------------------------ */
/*  Save as :   cb02.c                  */
/* ------------------------------------ */
#include      "v_a.h"
#include  "d_strct.h"
#include "d_lastr1.h"
#include    "d_guv.h"
/* ------------------------------------ */
#define        N  (2*C5)
/* ------------------------------------ */
void fun(void)
{
double alpha = 0.;

double u[N] ={0,6,6,0,0,
              0,0,6,6,0};

double **U  =             ca_A_mR(u,i_mR(R2,C5));
double **V  =                       i_mR(R2,C5);
double **T  =     Rot2D_mR(eye_mR(  i_mR(R3,C3)),PI/180.*alpha);
double **Ut =   c_mR(U,lastr_1_mR(  i_mR(R3,C5)));
double **Vt =                       i_mR(R3,C5);

  do
  {
   pause(); 
   Rot2D_mR(T,PI/180.*alpha);
     mul_mR(T,Ut,Vt);

   G_uv_mR(i_WGnuplot(-20,20,-10,10),Ut,Vt);
  } while(++alpha<360);

  f_mR(U);
  f_mR(V);
  f_mR(T);
  f_mR(Ut);
  f_mR(Vt);
}
/* ------------------------------------ */
void hello(void)
{
  printf("\n\n\n                                              ");
  printf("\n          Rotation about the origin  :            ");
  printf("\n          *************************               ");
  printf("\n\n              Animation                         ");
  printf("\n\n                                                ");
  printf("\n               | cos(alpha)  -sin(alpha)   0 |    ");
  printf("\n          v  = | sin(alpha)   cos(alpha)   0 |  u ");
  printf("\n               |          0           0    1 |\n\n");
  printf("\n\n                                              \n");
  printf("  * open the file main.plt with Gnuplot.            ");
  printf("                                          \n\n\n\n\n");
}
/* ------------------------------------ */
int main(void)
{
  hello();
    fun();
    
  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
cb03.c
/* ------------------------------------ */
/*  Save as :   cb03.c                  */
/* ------------------------------------ */
#include      "v_a.h"
#include  "d_strct.h"
#include "d_lastr1.h"
#include   "d_gpuv.h"
/* ------------------------------------ */
#define       Np  (2*C1)
#define        N  (2*C5)
#define    ALPHA  (40.)
/* ------------------------------------ */
void fun(void)
{
double u[N] ={0,6,6,0,0,
              0,0,6,6,0 };
              
double p[N] ={+4,
              -2};
              
double **U  =           ca_A_mR(u,i_mR(R2,C5));
double **V  =                     i_mR(R2,C5);
double **P  =           ca_A_mR(p,i_mR(R2,C1));
double **T  =            eye_mR(  i_mR(R3,C3));
double **Ut = c_mR(U,lastr_1_mR(  i_mR(R3,C5)));
double **Vt =                     i_mR(R3,C5);

  Rot2D_P_mR(T,P,PI/180.*ALPHA);

  clrscrn();
  printf("\n Rotation (%.f degree) : \n\n",ALPHA);
  printf(" P:");
  p_mR(P,S5,P0,C9);

  printf(" T:");
  p_mR(T,S8,P2,C9);

  printf(" U:");
  p_mR(U,S8,P2,C9);

  printf(" V:");
  mul_mR(T,Ut,Vt);
  c_nr_mR(Vt,R2,V);
  p_mR(V,S8,P2,C9);

  G_p_uv_mR(i_WGnuplot(-20,20,-10,10),Ut,Vt,P);
  printf("  * open the file main.plt with Gnuplot. \n\n\n");
  stop();

  f_mR(U);
  f_mR(V);
  f_mR(P);
  f_mR(T);
  f_mR(Ut);
  f_mR(Vt);
}
/* ------------------------------------ */
void hello(void)
{
  printf("\n\n\n                                              ");
  printf("\n          Rotation about a point P(xp,yp) :       ");
  printf("\n          **************************              ");
  printf("\n\n                                                ");
  printf("\n\n                                                ");
  printf("\n      | cos(A)  -sin(A)   xp(1-cos(A))+yp sin(A)| ");
  printf("\n v  = | sin(A)   cos(A)   yp(1-cos(A))+xp sin(A)|  u ");
  printf("\n      |     0        0                        1 |\n\n");
  printf("\n\n                                                ");
  printf("                                          \n\n\n\n\n");
  stop();
}
/* ------------------------------------ */
int main(void)
{
  hello();
    fun();
    
  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
cb04.c
/* ------------------------------------ */
/*  Save as :   cb04.c                  */
/* ------------------------------------ */
#include      "v_a.h"
#include  "d_strct.h"
#include "d_lastr1.h"
#include   "d_gpuv.h"
/* ------------------------------------ */
#define   CN 5
#define    N (2*CN)
/* ------------------------------------ */
void fun(void)
{
double alpha = 0;

double u[N] ={0,6,6,0,0,
              0,0,6,6,0};
              
double p[N] ={+4,
              -2};
                            
double **U  =           ca_A_mR(u,i_mR(R2,C5));
double **V  =                     i_mR(R2,C5);
double **P  =           ca_A_mR(p,i_mR(R2,C1));
double **T  =            eye_mR(  i_mR(R3,C3));
double **Ut = c_mR(U,lastr_1_mR(  i_mR(R3,C5)));
double **Vt =                     i_mR(R3,C5);

  do
  {
   pause();  
   Rot2D_P_mR(T,P,PI/180.*alpha);
   mul_mR(T,Ut,Vt);

    G_p_uv_mR(i_WGnuplot(-20,20,-10,10),Ut,Vt,P);
  } while(++alpha<360);

  f_mR(U);
  f_mR(V);
  f_mR(P);
  f_mR(T);
  f_mR(Ut);
  f_mR(Vt);
}
/* ------------------------------------ */
void hello(void)
{
  printf("\n\n\n                                              ");
  printf("\n          Rotation about a point P(xp,yp) :       ");
  printf("\n          **************************              ");
  printf("\n\n              Animation                         ");
  printf("\n\n                                                ");
  printf("\n      | cos(A)  -sin(A)   xp(1-cos(A))+yp sin(A)| ");
  printf("\n v  = | sin(A)   cos(A)   yp(1-cos(A))+xp sin(A)|  u ");
  printf("\n      |     0        0                        1 |\n\n");
  printf("  * open the file main.plt with Gnuplot.            ");
  printf("                                          \n\n\n\n\n");
}
/* ------------------------------------ */
int main(void)
{
  hello();
    fun();
    
  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */