| 1 | #include <stdlib.h> | 
|---|
| 2 | #include <stdio.h> | 
|---|
| 3 | #include <string.h> | 
|---|
| 4 |  | 
|---|
| 5 | #include "machdefs.h" | 
|---|
| 6 | #include "fmath.h" | 
|---|
| 7 |  | 
|---|
| 8 | #include "transfost.h" | 
|---|
| 9 |  | 
|---|
| 10 | /* Nouvelle-Fonction */ | 
|---|
| 11 | void PrintTransfo(TRANSFO *tr) | 
|---|
| 12 |  | 
|---|
| 13 | /*  Impression des coefficients du 1er ordre  */ | 
|---|
| 14 | { | 
|---|
| 15 | int k; | 
|---|
| 16 | char sg[3],sgp[3],*st[2]; | 
|---|
| 17 |  | 
|---|
| 18 | strcpy(sg,"XY"); strcpy(sgp,"xy"); | 
|---|
| 19 | st[0] = "Source";  st[1] = "Dest"; | 
|---|
| 20 |  | 
|---|
| 21 | printf("PrintTransfo:  Degre = %d (Coeff d'ordre 1) \n", tr->DegPolxy); | 
|---|
| 22 | for(k=0; k<2; k++) | 
|---|
| 23 | printf(" T%c %c = %10.5f  + %10.5f x + %10.5f y \n", sgp[k], sg[k], | 
|---|
| 24 | tr->Polxy[0][0][k], tr->Polxy[1][0][k], tr->Polxy[0][1][k]); | 
|---|
| 25 |  | 
|---|
| 26 | for(k=0; k<2; k++) | 
|---|
| 27 | { | 
|---|
| 28 | printf("Lim[%6s] MidX,Y= %10g %10g  LargX,Y= %10g %10g\n", | 
|---|
| 29 | st[k],tr->midx[k], tr->midy[k], tr->largx[k], tr->largy[k]); | 
|---|
| 30 | printf("   XMin,Max= %10g %10g   YMin,Max= %10g %10g \n", | 
|---|
| 31 | tr->xmin[k], tr->xmax[k], tr->ymin[k], tr->ymax[k]); | 
|---|
| 32 | } | 
|---|
| 33 |  | 
|---|
| 34 | return; | 
|---|
| 35 | } | 
|---|
| 36 |  | 
|---|
| 37 |  | 
|---|
| 38 | /* Nouvelle-Fonction */ | 
|---|
| 39 | void RedCord(double x, double y, double *xr, double *yr, TRANSFO *transf, int i) | 
|---|
| 40 | { | 
|---|
| 41 | *xr = (x - transf->midx[i]) / transf->largx[i]; | 
|---|
| 42 | *yr = (y - transf->midy[i]) / transf->largy[i]; | 
|---|
| 43 | } | 
|---|
| 44 |  | 
|---|
| 45 |  | 
|---|
| 46 | /* Nouvelle-Fonction */ | 
|---|
| 47 | void ExpCord(double xr, double yr, double *x, double *y, TRANSFO *transf, int i) | 
|---|
| 48 | { | 
|---|
| 49 | *x = transf->largx[i] * xr + transf->midx[i]; | 
|---|
| 50 | *y = transf->largy[i] * yr + transf->midy[i]; | 
|---|
| 51 | } | 
|---|
| 52 |  | 
|---|
| 53 |  | 
|---|
| 54 | /* Nouvelle-Fonction */ | 
|---|
| 55 | void CordTransf(double xS, double yS, double *xD, double *yD, TRANSFO *transf) | 
|---|
| 56 | { | 
|---|
| 57 | double xi,yi,xo,yo,xk,yl; | 
|---|
| 58 | int k,l; | 
|---|
| 59 |  | 
|---|
| 60 | RedCord(xS,yS,&xi,&yi,transf,0); | 
|---|
| 61 | if (transf->DegPolxy == 1) { | 
|---|
| 62 | xo = transf->Polxy[0][0][0] + transf->Polxy[1][0][0]*xi + transf->Polxy[0][1][0]*yi; | 
|---|
| 63 | yo = transf->Polxy[0][0][1] + transf->Polxy[1][0][1]*xi + transf->Polxy[0][1][1]*yi; | 
|---|
| 64 | } | 
|---|
| 65 | else { | 
|---|
| 66 | xo = yo = 0.0; | 
|---|
| 67 | xk = 1.0; | 
|---|
| 68 | for (k = 0; k<=transf->DegPolxy; k++) { | 
|---|
| 69 | yl = 1.0; | 
|---|
| 70 | for (l = 0; l<=transf->DegPolxy-k; l++) { | 
|---|
| 71 | xo += transf->Polxy[k][l][0]*xk*yl; | 
|---|
| 72 | yo += transf->Polxy[k][l][1]*xk*yl; | 
|---|
| 73 | yl *= yi; | 
|---|
| 74 | } | 
|---|
| 75 | xk *= xi; | 
|---|
| 76 | } | 
|---|
| 77 | } | 
|---|
| 78 | ExpCord(xo,yo,xD,yD,transf,1); | 
|---|
| 79 | } | 
|---|
| 80 |  | 
|---|
| 81 |  | 
|---|
| 82 | /* Nouvelle-Fonction */ | 
|---|
| 83 | void CordTransfEros2(double xS,double yS,double *xD,double *yD,TRANSFO *transf) | 
|---|
| 84 | /* | 
|---|
| 85 | Dans Eros2 les infos concernant les coordonnees reduites sont codees | 
|---|
| 86 | dans TRANSFO mais la transformation est donnee pour les coordonnees normales | 
|---|
| 87 | */ | 
|---|
| 88 | { | 
|---|
| 89 | double xk,yl; | 
|---|
| 90 | int k,l; | 
|---|
| 91 |  | 
|---|
| 92 | if (transf->DegPolxy == 1) { | 
|---|
| 93 | *xD = transf->Polxy[0][0][0] + transf->Polxy[1][0][0]*xS + transf->Polxy[0][1][0]*yS; | 
|---|
| 94 | *yD = transf->Polxy[0][0][1] + transf->Polxy[1][0][1]*xS + transf->Polxy[0][1][1]*yS; | 
|---|
| 95 | } | 
|---|
| 96 | else { | 
|---|
| 97 | *xD = *yD = 0.0; | 
|---|
| 98 | xk = 1.0; | 
|---|
| 99 | for (k = 0; k<=transf->DegPolxy; k++) { | 
|---|
| 100 | yl = 1.0; | 
|---|
| 101 | for (l = 0; l<=transf->DegPolxy-k; l++) { | 
|---|
| 102 | *xD += transf->Polxy[k][l][0]*xk*yl; | 
|---|
| 103 | *yD += transf->Polxy[k][l][1]*xk*yl; | 
|---|
| 104 | yl *= yS; | 
|---|
| 105 | } | 
|---|
| 106 | xk *= xS; | 
|---|
| 107 | } | 
|---|
| 108 | } | 
|---|
| 109 | } | 
|---|