MAGiC  V5.0
Mailleurs Automatiques de Géometries intégrés à la Cao
fct_generateur_calibrage.cpp
Aller à la documentation de ce fichier.
1 //####//------------------------------------------------------------
2 //####//------------------------------------------------------------
3 //####// MAGiC
4 //####// Jean Christophe Cuilliere et Vincent FRANCOIS
5 //####// Departement de Genie Mecanique - UQTR
6 //####//------------------------------------------------------------
7 //####// MAGIC est un projet de recherche de l equipe ERICCA
8 //####// du departement de genie mecanique de l Universite du Quebec a Trois Rivieres
9 //####// http://www.uqtr.ca/ericca
10 //####// http://www.uqtr.ca/
11 //####//------------------------------------------------------------
12 //####//------------------------------------------------------------
13 //####//
14 //####// fct_generateur_calibrage.cpp
15 //####//
16 //####//------------------------------------------------------------
17 //####//------------------------------------------------------------
18 //####// COPYRIGHT 2000-2024
19 //####// jeu 13 jun 2024 11:58:52 EDT
20 //####//------------------------------------------------------------
21 //####//------------------------------------------------------------
22 #include "gestionversion.h"
23 #pragma hdrstop
24 
25 #include <math.h>
27 #pragma package(smart_init)
28 
29 
30 
31 FCT_GENERATEUR_CALIBRAGE::FCT_GENERATEUR_CALIBRAGE(double dn,double eniarg,double courb,double lambdaarg,double nor):FCT_GENERATEUR_ECHANTILLONAGE_ESTIMATION(dn,4,nor),eni(eniarg),lambda(lambdaarg),courbure(courb)
32 {
33 }
34 
36 {
37 }
38 
40 {}
42 {}
44 {
48  xmin=-55*yentredeux;
49  ymin=-55*yentredeux;
50  zmin=-55*yentredeux;
51  xmax=55*yentredeux;
52  ymax=55*yentredeux;
53  zmax=55*yentredeux;
55  grille.initialiser(boite.get_xmin(),boite.get_ymin(),boite.get_zmin(),boite.get_xmax(),boite.get_ymax(),boite.get_zmax(),1,1,1);
56  int nb_point=lstpoint.get_nb();
57  for (int i=0;i<nb_point;i++)
59 }
60 
62 {
63  return yentredeux;
64 }
65 
67 {
68  double deltaen=0.25*eni;
69  double rc;
70  if (courbure<0) rc=deltaen/((dng-eni-deltaen)*zonetrans+deltaen);
71  else rc=-0.05/courbure/zonetrans/(deltaen-dng+eni)*(sqrt((deltaen*(zonetrans-1)-zonetrans*(dng-eni))*(deltaen*(zonetrans-1)-zonetrans*(dng-eni))-40*courbure*deltaen*zonetrans*(deltaen-dng+eni))+deltaen*(zonetrans-1)-zonetrans*(dng-eni));
72  double dc=2*lambda*(dng-eni)*rc;
73  yentredeux=dc/2. ;
74  for (int i=0;i<10;i++)
75  {
76  double x=0.,y,z=0.;
77  y=(9-2*i)*dc/2.;
78  double dist=(dng-eni)*lambda;
79  BOITE_3D boite(x-dist,y-dist,z-dist,x+dist,y+dist,z+dist);
80  DOUBLEN<1> ecart(&eni);
81  CT_POINT<1>* pt=new CT_POINT<1>(x,y,z,ecart,boite,courbure);
82  lstpoint.ajouter(pt);
83  }
84 }
85 
86 
87 
88 long fibo(long n)
89 {
90  if (n<2) return 1;
91  return fibo(n-1)+fibo(n-2);
92 }
93 
94 
95 
96 double f(double x,long nb,double *xfonc,double *fonc,double eng,double eni,double lambda,double nor,double *fonc2)
97 {
98  FCT_GENERATEUR_CALIBRAGE carte(eng,eni,x,lambda,nor);
99  carte.construit();
100  double y=carte.get_y();
101  double res=0.0;
102  for (int i=0;i<nb;i++)
103  {
104  double val=carte.estimer(xfonc[i],0.,0.);
105  if (fonc2!=NULL) fonc2[i]=val;
106  val=val-fonc[i];
107  res=res+val*val;
108  val=carte.estimer(xfonc[i],y,0.);
109  if (fonc2!=NULL) fonc2[i+nb]=val;
110  val=val-fonc[i];
111  res=res+val*val;
112  }
113  return res/2./nb;
114 }
115 
116 
117 double calibre_courbure(long nb,double *xfonc,double *fonc,double binf,double bsup,double nor,double dx,double *fonc2)
118 {
119  double eng=fonc[nb-1];
120  double eni=fonc[0];
121  double lambda=(xfonc[nb-1]-xfonc[0])/(eng-eni);
122  double lon=dx;
123  double eps=dx/1000.;
124  double a=binf;
125  double b=bsup;
126  int n=2;
127  do
128  {
129  n++;
130  }
131  while (fibo(n)<(b-a)/lon);
132  double l=a+fibo(n-2)*1./fibo(n)*(b-a);
133  double u=a+fibo(n-1)*1./fibo(n)*(b-a);
134  double tetai=f(l,nb,xfonc,fonc,eng,eni,lambda,nor);
135  double tetaii=f(u,nb,xfonc,fonc,eng,eni,lambda,nor);
136  int k=1;
137  do
138  {
139  if (tetai>tetaii)
140  {
141  a=l;
142  l=u;
143  u=a+fibo(n-k-1)*1./fibo(n-k)*(b-a);
144  }
145  else
146  {
147  b=u;
148  u=l;
149  l=a+fibo(n-k-2)*1./fibo(n-k)*(b-a);
150  }
151  tetai=f(l,nb,xfonc,fonc,eng,eni,lambda,nor);
152  tetaii=f(u,nb,xfonc,fonc,eng,eni,lambda,nor);
153  k++;
154  }
155  while (k<n-1);
156  u=l+eps;
157  tetai=f(l,nb,xfonc,fonc,eng,eni,lambda,nor);
158  tetaii=f(u,nb,xfonc,fonc,eng,eni,lambda,nor);
159  if (tetai>tetaii) a=l;
160  else b=l;
161  double res=0.5*(a+b);
162  if (fonc2!=NULL)
163  f(res,nb,xfonc,fonc,eng,eni,lambda,nor,fonc2);
164  return 0.5*(a + b);
165 
166 }
FCT_GENERATEUR_ECHANTILLONAGE_ESTIMATION::xmax
double xmax
Definition: fct_generateur_echantillonage_estimation.h:51
FCT_GENERATEUR_CALIBRAGE::construit
void construit(int n1=0, int n2=0, class MG_GROUPE_TOPOLOGIQUE *mggt=NULL)
Definition: fct_generateur_calibrage.cpp:43
FCT_GENERATEUR_ECHANTILLONAGE_ESTIMATION::lstpoint
TPL_LISTE_ENTITE< CT_POINT< 1 > * > lstpoint
Definition: fct_generateur_echantillonage_estimation.h:52
FCT_GENERATEUR_CALIBRAGE::enregistrer
void enregistrer(char *mess)
Definition: fct_generateur_calibrage.cpp:39
gestionversion.h
fct_generateur_calibrage.h
BOITE_3D::get_xmin
double get_xmin(void)
Definition: ot_boite_3d.cpp:104
FCT_GENERATEUR_ECHANTILLONAGE_ESTIMATION::xmin
double xmin
Definition: fct_generateur_echantillonage_estimation.h:50
a
#define a(i, j)
FCT_GENERATEUR_CALIBRAGE
Definition: fct_generateur_calibrage.h:33
FCT_GENERATEUR_CALIBRAGE::~FCT_GENERATEUR_CALIBRAGE
~FCT_GENERATEUR_CALIBRAGE()
Definition: fct_generateur_calibrage.cpp:35
FCT_GENERATEUR_CALIBRAGE::FCT_GENERATEUR_CALIBRAGE
FCT_GENERATEUR_CALIBRAGE(double dn, double eniarg, double courb, double lambdaarg, double nor=1.0)
Definition: fct_generateur_calibrage.cpp:31
CT_POINT
Definition: ct_point.h:31
FCT_GENERATEUR_CALIBRAGE::echantillonner
void echantillonner(class MG_GROUPE_TOPOLOGIQUE *mggt=NULL)
Definition: fct_generateur_calibrage.cpp:66
FCT_GENERATEUR_3D< 4 >::grille
TPL_GRILLE_INFO< CT_POINT< 1 > *, DOUBLEN< N > > grille
Definition: fct_generateur_3d.h:56
FCT_GENERATEUR_CALIBRAGE::get_y
double get_y(void)
Definition: fct_generateur_calibrage.cpp:61
BOITE_3D::get_zmax
double get_zmax(void)
Definition: ot_boite_3d.cpp:129
BOITE_3D::get_ymin
double get_ymin(void)
Definition: ot_boite_3d.cpp:114
f
double f(double x, long nb, double *xfonc, double *fonc, double eng, double eni, double lambda, double nor, double *fonc2)
Definition: fct_generateur_calibrage.cpp:96
FCT_GENERATEUR_ECHANTILLONAGE_ESTIMATION::ymax
double ymax
Definition: fct_generateur_echantillonage_estimation.h:51
BOITE_3D::get_xmax
double get_xmax(void)
Definition: ot_boite_3d.cpp:109
FCT_GENERATEUR_ECHANTILLONAGE_ESTIMATION::ymin
double ymin
Definition: fct_generateur_echantillonage_estimation.h:50
FCT_GENERATEUR_CALIBRAGE::courbure
double courbure
Definition: fct_generateur_calibrage.h:48
TPL_LISTE_ENTITE::ajouter
virtual void ajouter(X x)
Definition: tpl_liste_entite.h:38
TPL_LISTE_ENTITE::get_nb
virtual int get_nb(void)
Definition: tpl_liste_entite.h:67
FCT_GENERATEUR_CALIBRAGE::lire
void lire(char *mess)
Definition: fct_generateur_calibrage.cpp:41
TPL_LISTE_ENTITE::get
virtual X get(int num)
Definition: tpl_liste_entite.h:72
BOITE_3D::get_ymax
double get_ymax(void)
Definition: ot_boite_3d.cpp:119
TPL_GRILLE_INFO::inserer
virtual void inserer(A a)
Definition: tpl_grille.h:480
FCT_GENERATEUR_ECHANTILLONAGE_ESTIMATION::zmin
double zmin
Definition: fct_generateur_echantillonage_estimation.h:50
BOITE_3D
Definition: ot_boite_3d.h:27
FCT_GENERATEUR_ECHANTILLONAGE_ESTIMATION::pas_echantillon
int pas_echantillon
Definition: fct_generateur_echantillonage_estimation.h:44
FCT_GENERATEUR_CALIBRAGE::lambda
double lambda
Definition: fct_generateur_calibrage.h:47
sqrt
double2 sqrt(double2 &val)
Definition: ot_doubleprecision.cpp:345
MG_GROUPE_TOPOLOGIQUE
Definition: mg_groupe_topologique.h:31
FCT_GENERATEUR_ECHANTILLONAGE_ESTIMATION::zonetrans
double zonetrans
Definition: fct_generateur_echantillonage_estimation.h:47
FCT_GENERATEUR_ECHANTILLONAGE_ESTIMATION::pas_estimation
int pas_estimation
Definition: fct_generateur_echantillonage_estimation.h:45
FCT_GENERATEUR_ECHANTILLONAGE_ESTIMATION::zmax
double zmax
Definition: fct_generateur_echantillonage_estimation.h:51
BOITE_3D::get_zmin
double get_zmin(void)
Definition: ot_boite_3d.cpp:124
TPL_GRILLE_INFO::initialiser
virtual void initialiser(double xmin, double ymin, double zmin, double xmax, double ymax, double zmax, int nb_pasx, int nb_pasy, int nb_pasz)
Definition: tpl_grille.h:388
FCT_GENERATEUR_ECHANTILLONAGE_ESTIMATION::estimer
virtual double estimer(double x, double y, double z)
Definition: fct_generateur_echantillonage_estimation.cpp:130
res
#define res(i, j)
FCT_GENERATEUR_CALIBRAGE::yentredeux
double yentredeux
Definition: fct_generateur_calibrage.h:49
fibo
long fibo(long n)
Definition: fct_generateur_calibrage.cpp:88
DOUBLEN< 1 >
FCT_GENERATEUR_ECHANTILLONAGE_ESTIMATION
Definition: fct_generateur_echantillonage_estimation.h:31
FCT_GENERATEUR_ECHANTILLONAGE_ESTIMATION::dng
double dng
Definition: fct_generateur_echantillonage_estimation.h:48
FCT_GENERATEUR_CALIBRAGE::eni
double eni
Definition: fct_generateur_calibrage.h:46
calibre_courbure
double calibre_courbure(long nb, double *xfonc, double *fonc, double binf, double bsup, double nor, double dx, double *fonc2)
Definition: fct_generateur_calibrage.cpp:117