source: Sophya/trunk/Poubelle/archediab.old/archediab.sources/c/foyer.c@ 637

Last change on this file since 637 was 637, checked in by ansari, 26 years ago

archediab version 24 initial import

File size: 2.8 KB
Line 
1#include "diabolo.h"
2#include "foyer.h"
3
4
5void fit_foyer(void);
6
7
8
9#define indicemax 500
10
11static int bolo,indice;
12
13static double carte[nb_max_bolo][6]; // pour sommer chaque subscan
14
15
16
17//-------------------- fonction exec de la fenetre : foyer -------------------------------
18
19
20void exec_foyer(int fen,int item,double valeur,...)
21{
22
23switch(item)
24 {
25 case ouverture : gg->trace_ouvert=gg->trace_ouvert | 16 ;
26 selectgra(fen);
27
28 graph->taille_graduations=7;
29 indice=0;
30 bolo=litD(fen,foy_bolo,0);
31 break;
32
33
34
35
36
37 case fermeture : gg->trace_ouvert=gg->trace_ouvert & (255-16); // enleve le 16
38 break;
39
40 case foy_pas :
41 case foy_bolo : bolo=litD(fen,foy_bolo,0);
42 fit_foyer();
43 break;
44 default : break;
45 }
46}
47
48
49
50void trace_foyer(double *y)
51{
52int j;
53// gg->compte_subscan contient le N° de subscan et est negatif entre 2 subscans
54
55
56if( (gg->compte_subscan<1) ou (gg->compte_subscan>6) )
57 {
58 if(indice>0)
59 {
60 int s=-gg->compte_subscan;
61 if( (s>=1) && (s<=6) )
62 {
63 for(j=0;j<nb_max_bolo;j++) carte[j][s-1]/=(double)indice;
64 printf("-> valeur x[%d]=%g \n",bolo,carte[bolo-1][s-1]);
65 }
66 }
67 if( (indice>0) && (gg->compte_subscan==-6) ) fit_foyer();
68 indice=0;
69// printf("ne trace pas un point (entre 2 subscans) \n");
70 return;
71 }
72
73if(indice==0)
74 {
75 printf("debut subscan %d ",gg->compte_subscan);
76 selectgra(fenetre_annexe);
77 graph->couleur_trace=gg->compte_subscan+1;
78 style(fenetre_annexe);
79 for(j=0;j<nb_max_bolo;j++) carte[j][gg->compte_subscan-1]=0;
80 }
81
82printf("%d ",indice);
83
84for(j=0;j<nb_max_bolo;j++) carte[j][gg->compte_subscan-1]+=y[j];
85
86trace(fenetre_annexe,indice,y[bolo-1]);
87if(indice<indicemax) indice++;
88}
89
90#define xcorr(x) (((x)-1)*pas)
91
92
93void fit_foyer(void)
94{
95double a,b,c,y0,y1,y2,xmini,x;
96int i;
97double pas=litD(fenetre_annexe,foy_pas,0);
98char ss[255];
99
100// x=0,1,2
101
102y0=0.5*(carte[bolo-1][0]+carte[bolo-1][5]);
103y1=0.5*(carte[bolo-1][1]+carte[bolo-1][4]);
104y2=0.5*(carte[bolo-1][2]+carte[bolo-1][3]);
105c=y0;
106a=0.5*(c-2*y1+y2);
107b=y1-c-a;
108// cherche le minimum
109xmini=-0.5*b/a;
110xmini=xcorr(xmini);
111
112efface(fenetre_annexe);
113selectgra(fenetre_annexe);
114graph->couleur_trace=rouge;
115graph->couleur_texte=violet;graph->taille_texte=16;
116graph->type_symbole=rondplein;graph->taille_symbole=5;graph->ligne_trace=0;
117style(fenetre_annexe);
118
119for(i=0;i<3;i++) trace(fenetre_annexe,xcorr(i),carte[bolo-1][i]);
120for(i=0;i<3;i++) trace(fenetre_annexe,xcorr(i),carte[bolo-1][5-i]);
121
122graph->type_symbole=rien;graph->ligne_trace=1;
123graph->couleur_trace=bleu;
124style(fenetre_annexe);
125
126for(x=-0.4;x<2.4;x+=0.05) trace(fenetre_annexe,xcorr(x),a*x*x+b*x+c);
127
128autox(fenetre_annexe);autoy(fenetre_annexe);retrace(fenetre_annexe);
129
130place(fenetre_annexe,-0.9,3*a+b+c);
131
132sprintf(ss,"correction %4.1f",xmini);
133texte(fenetre_annexe,0,ss);
134
135}
136
137
138
Note: See TracBrowser for help on using the repository browser.