Mathc matrices/a138

Un livre de Wikilivres.


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.

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

double **U  =           ca_A_mR(u,i_mR(R2,C5));
double **V  =                     i_mR(R2,C5);
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);

  c_s_mR(SX,T,R1,C1);

  clrscrn();
  printf(" T:\n");
  p_mR(T,S5,P0,C9);

  printf(" U:\n");
  p_mR(U,S3,P0,C9);

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

  G_uv_mR(i_WGnuplot(-30,30,-15,15),
                U,V);

  printf("  * open the file main.plt with Gnuplot. \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       Scaling relative to the origine  :         ");
  printf("\n       *******************************            ");
  printf("\n\n                                                ");
  printf("\n\n                                                ");
  printf("\n                | Sx  0  0 |                      ");
  printf("\n           v  = | 0   1  0 |  u                   ");
  printf("\n                | 0   0  1 |                      ");
  printf("\n\n                                                ");
  printf("\n Sx: x-axis scaling factor                        ");
  printf("                                          \n\n\n\n\n");
  stop();
}
/* ------------------------------------ */
int main(void)
{
  hello();
    fun();
    
  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
cg02.c
/* ------------------------------------ */
/*  Save as :   cg02.c                  */
/* ------------------------------------ */
#include      "v_a.h"
#include  "d_strct.h"
#include "d_lastr1.h"
#include    "d_guv.h"
/* ------------------------------------ */
#define N  (2*C5)
#define SY (4.)
/* ------------------------------------ */
void fun(void)
{
double u[N] ={0,6,6,0,0,
              0,0,4,4,0};

double **U  =           ca_A_mR(u,i_mR(R2,C5));
double **V  =                     i_mR(R2,C5);
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);

  c_s_mR(SY,T,R2,C2);

  clrscrn();
  printf(" T:");
  p_mR(T,S5,P0,C9);

  printf(" U:");
  p_mR(U,S3,P0,C9);

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

  G_uv_mR(i_WGnuplot(-30,30,-5,20),
                U,V);

  printf("  * open the file main.plt with Gnuplot. \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       Scaling relative to the origine  :         ");
  printf("\n       *******************************            ");
  printf("\n\n                                                ");
  printf("\n\n                                                ");
  printf("\n                | 1  0   0 |                      ");
  printf("\n           v  = | 0  Sy  0 |  u                   ");
  printf("\n                | 0   0  1 |                      ");
  printf("\n\n                                                ");
  printf("\n Sy: y-axis scaling factor                        ");
  printf("                                          \n\n\n\n\n");
  stop();
}
/* ------------------------------------ */
int main(void)
{
  hello();
    fun();
    
  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
cg03.c
/* ------------------------------------ */
/*  Save as :   cg03.c                  */
/* ------------------------------------ */
#include      "v_a.h"
#include  "d_strct.h"
#include "d_lastr1.h"
#include    "d_guv.h"
/* ------------------------------------ */
#define N  (2*C5)
#define SX (4.)
#define SY (4.)
/* ------------------------------------ */
void fun(void)
{
double u[N] ={0,6,6,0,0,
              0,0,4,4,0};

double **U  =           ca_A_mR(u,i_mR(R2,C5));
double **V  =                     i_mR(R2,C5);
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);

  c_s_mR(SX,T,R1,C1);
  c_s_mR(SY,T,R2,C2);

  clrscrn();
  printf(" T:");
  p_mR(T,S5,P0,C9);

  printf(" U:");
  p_mR(U,S3,P0,C9);

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

  G_uv_mR(i_WGnuplot(-40,40,-20,20),
                U,V);

  printf("  * open the file main.plt with Gnuplot. \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       Scaling relative to the origine  :         ");
  printf("\n       *******************************            ");
  printf("\n\n                                                ");
  printf("\n\n                                                ");
  printf("\n                | Sx  0  0 |                      ");
  printf("\n           v  = | 0  Sy  0 |  u                   ");
  printf("\n                | 0   0  1 |                      ");
  printf("                                          \n\n\n\n\n");
  stop();
}
/* ------------------------------------ */
int main(void)
{
  hello();
    fun();
    
  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
cg04.c
/* ------------------------------------ */
/*  Save as :   cg04.c                  */
/* ------------------------------------ */
#include      "v_a.h"
#include  "d_strct.h"
#include "d_lastr1.h"
#include   "d_gpuv.h"
/* ------------------------------------ */
#define N  (2*C5)
#define SX (4.)
#define PX (10.)
/* ------------------------------------ */
void fun(void)
{
double u[N] ={0,6,6,0,0,
              0,0,4,4,0};
              
double p[N] ={PX,
              0 };
              
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);

 c_s_mR(SX,         T,R1,C1);
 c_s_mR((PX*(1-SX)),T,R1,C3);

  clrscrn();
  printf(" T:");
  p_mR(T,5,0,C9);

  printf(" U:");
  p_mR(U,S3,P0,C9);

  printf(" P:");
  p_mR(P,S5,P0,C9);

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

   G_p_uv_mR(i_WGnuplot(-40,40,-20,20),U,V,P);

  printf("  * open the file main.plt with Gnuplot. \n\n");
  stop();

  f_mR(U);
  f_mR(P);
  f_mR(V);
  f_mR(T);
  f_mR(Ut);
  f_mR(Vt);
}
/* ------------------------------------ */
void hello(void)
{
  printf("\n\n\n                                              ");
  printf("\n       Scaling relative to a point P(xp,0) :      ");
  printf("\n       *******************************            ");
  printf("\n\n                                                ");
  printf("\n\n                                                ");
  printf("\n                | Sx  0  xp(1-Sx) |               ");
  printf("\n           v  = | 0   1  0        |  u            ");
  printf("\n                | 0   0  1        |               ");
  printf("\n\n                                                ");
  printf("\n Sx: x-axis scaling factor                        ");
  printf("                                          \n\n\n\n\n");
  stop();
}
/* ------------------------------------ */
int main(void)
{
  hello();
    fun();
    
  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
cg05.c
/* ------------------------------------ */
/*  Save as :   cg05.c                  */
/* ------------------------------------ */
#include      "v_a.h"
#include  "d_strct.h"
#include "d_lastr1.h"
#include   "d_gpuv.h"
/* ------------------------------------ */
#define N  (2*C5)
#define SY (4.)
#define PY (10.)
/* ------------------------------------ */
void fun(void)
{
double u[N] ={0,6,6,0,0,
              0,0,4,4,0};
              
double p[N] ={0,
              PY };
              
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);

 c_s_mR(SY,         T,R2,C2);
 c_s_mR((PY*(1-SY)),T,R2,C3);

  clrscrn();
  printf(" T:");
  p_mR(T,5,0,C9);

  printf(" U:");
  p_mR(U,S3,P0,C9);

  printf(" P:");
  p_mR(P,S5,P0,C9);

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

   G_p_uv_mR(i_WGnuplot(-30,30,-35,20),
                    U,V,P);

  printf("  * open the file main.plt with Gnuplot. \n\n");
  stop();

  f_mR(U);
  f_mR(P);
  f_mR(V);
  f_mR(T);
  f_mR(Ut);
  f_mR(Vt);
}
/* ------------------------------------ */
void hello(void)
{
  printf("\n\n\n                                              ");
  printf("\n       Scaling relative to a point P(0,yp) :     ");
  printf("\n       *******************************            ");
  printf("\n\n                                                ");
  printf("\n\n                                                ");
  printf("\n                | 1   0   0        |              ");
  printf("\n           v  = | 0   Sy  yp(1-Sy) |  u           ");
  printf("\n                | 0   0   1        |              ");
  printf("\n\n                                                ");
  printf("\n Sy: y-axis scaling factor                        ");
  printf("                                          \n\n\n\n\n");
  stop();
}
/* ------------------------------------ */
int main(void)
{
  hello();
    fun();
    
  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
cg06.c
/* ------------------------------------ */
/*  Save as :   cg06.c                  */
/* ------------------------------------ */
#include      "v_a.h"
#include  "d_strct.h"
#include "d_lastr1.h"
#include   "d_gpuv.h"
/* ------------------------------------ */
#define N  (2*C5)
#define SX (4.)
#define PX (10.)
#define SY (4.)
#define PY (10.)
/* ------------------------------------ */
void fun(void)
{
double u[N] ={0,6,6,0,0,
              0,0,4,4,0};
              
double p[N] ={PX,
              PY};
              
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);

 c_s_mR(SX,         T,R1,C1);
 c_s_mR((PX*(1-SX)),T,R1,C3);
 c_s_mR(SY,         T,R2,C2);
 c_s_mR((PY*(1-SY)),T,R2,C3);

  clrscrn();
  printf(" T:");
  p_mR(T,S5,P0,C9);

  printf(" U:");
  p_mR(U,S3,P0,C9);

  printf(" P:");
  p_mR(P,S5,P0,C9);

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

   G_p_uv_mR(i_WGnuplot(-40,40,-35,20),
                    U,V,P);

  printf("  * open the file main.plt with Gnuplot. \n\n");
  stop();

  f_mR(U);
  f_mR(P);
  f_mR(V);
  f_mR(T);
  f_mR(Ut);
  f_mR(Vt);
}
/* ------------------------------------ */
void hello(void)
{
  printf("\n\n\n                                              ");
  printf("\n       Scaling relative to a point P(xp,yp) :     ");
  printf("\n       *******************************            ");
  printf("\n\n                                                ");
  printf("\n\n                                                ");
  printf("\n                | Sx  0  xp(1-Sx)  |              ");
  printf("\n           v  = | 0  Sy  yp(1-Sy)  |  u           ");
  printf("\n                | 0   0   1        |              ");
  printf("\n\n                                                ");
  printf("\n Sx: x-axis scaling factor                        ");
  printf("\n Sy: y-axis scaling factor                        ");
  printf("                                          \n\n\n\n\n");
  stop();
}
/* ------------------------------------ */
int main(void)
{
  hello();
    fun();
    
  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */