1 |
francois |
1156 |
//####//------------------------------------------------------------ |
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 |
|
|
//####// stellipse.cpp |
15 |
|
|
//####// |
16 |
|
|
//####//------------------------------------------------------------ |
17 |
|
|
//####//------------------------------------------------------------ |
18 |
|
|
//####// COPYRIGHT 2000-2024 |
19 |
|
|
//####// jeu 13 jun 2024 11:53:59 EDT |
20 |
|
|
//####//------------------------------------------------------------ |
21 |
|
|
//####//------------------------------------------------------------ |
22 |
francois |
283 |
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
#include "stellipse.h" |
26 |
|
|
#include "st_gestionnaire.h" |
27 |
|
|
#include "tpl_fonction.h" |
28 |
|
|
#include "constantegeo.h" |
29 |
|
|
|
30 |
|
|
#include <math.h> |
31 |
|
|
|
32 |
|
|
|
33 |
|
|
|
34 |
|
|
ST_ELLIPSE::ST_ELLIPSE(long LigneCourante,std::string idori,long axis2,double a,double b):ST_COURBE(LigneCourante,idori),id_axis2_placement_3d(axis2),a(a),b(b) |
35 |
|
|
{ |
36 |
|
|
} |
37 |
|
|
|
38 |
|
|
ST_ELLIPSE::ST_ELLIPSE(double *xyz,double *dirz,double *dirx,double a,double b):ST_COURBE(),a(a),b(b) |
39 |
|
|
{ |
40 |
|
|
initialiser(xyz,dirz,dirx); |
41 |
|
|
} |
42 |
|
|
|
43 |
|
|
|
44 |
|
|
long ST_ELLIPSE::get_id_axis2_placement_3d(void) |
45 |
|
|
{ |
46 |
|
|
return id_axis2_placement_3d; |
47 |
|
|
} |
48 |
|
|
double ST_ELLIPSE::get_a(void) |
49 |
|
|
{ |
50 |
|
|
return a; |
51 |
|
|
} |
52 |
|
|
double ST_ELLIPSE::get_b(void) |
53 |
|
|
{ |
54 |
|
|
return b; |
55 |
|
|
} |
56 |
|
|
void ST_ELLIPSE::evaluer(double t,double *xyz) |
57 |
|
|
{ |
58 |
|
|
OT_VECTEUR_3D local(a*cos(t),b*sin(t),0.); |
59 |
|
|
OT_VECTEUR_3D global=origine+repere*local; |
60 |
|
|
xyz[0]=global.get_x(); |
61 |
|
|
xyz[1]=global.get_y(); |
62 |
|
|
xyz[2]=global.get_z(); |
63 |
|
|
} |
64 |
|
|
void ST_ELLIPSE::deriver(double t,double *dxyz) |
65 |
|
|
{ |
66 |
|
|
OT_VECTEUR_3D local(-a*sin(t),b*cos(t),0.); |
67 |
|
|
OT_VECTEUR_3D global=repere*local; |
68 |
|
|
dxyz[0]=global.get_x(); |
69 |
|
|
dxyz[1]=global.get_y(); |
70 |
|
|
dxyz[2]=global.get_z(); |
71 |
|
|
} |
72 |
|
|
void ST_ELLIPSE::deriver_seconde(double t,double *ddxyz,double* dxyz ,double* xyz ) |
73 |
|
|
{ |
74 |
|
|
OT_VECTEUR_3D local(-a*cos(t),-b*sin(t),0.); |
75 |
|
|
OT_VECTEUR_3D global=repere*local; |
76 |
|
|
ddxyz[0]=global.get_x(); |
77 |
|
|
ddxyz[1]=global.get_y(); |
78 |
|
|
ddxyz[2]=global.get_z(); |
79 |
|
|
if (dxyz!=NULL) deriver(t,dxyz); |
80 |
|
|
if (xyz!=NULL) evaluer(t,xyz); |
81 |
|
|
} |
82 |
|
|
void ST_ELLIPSE::inverser(double& t,double *xyz,double precision) |
83 |
|
|
{ |
84 |
|
|
double sign; |
85 |
|
|
double valeur; |
86 |
|
|
OT_VECTEUR_3D global(xyz[0],xyz[1],xyz[2]); |
87 |
|
|
OT_MATRICE_3D transpose_repere; |
88 |
|
|
repere.transpose(transpose_repere); |
89 |
|
|
OT_VECTEUR_3D vecteur=transpose_repere*(global-origine); |
90 |
|
|
valeur=vecteur.get_x()/a; |
91 |
|
|
if (valeur>1) valeur=1; |
92 |
|
|
if (valeur<-1) valeur=-1; |
93 |
|
|
t=acos(valeur); |
94 |
|
|
sign=vecteur.get_y()/b; |
95 |
|
|
if (sign<-0.000001) t= 2.*M_PI-t; |
96 |
|
|
} |
97 |
|
|
double ST_ELLIPSE::get_tmin() |
98 |
|
|
{ |
99 |
|
|
return 0.; |
100 |
|
|
} |
101 |
|
|
double ST_ELLIPSE::get_tmax() |
102 |
|
|
{ |
103 |
|
|
return 2.*M_PI; |
104 |
|
|
} |
105 |
|
|
|
106 |
|
|
double equation_longueur(ST_ELLIPSE& ellipse,double t) |
107 |
|
|
{ |
108 |
|
|
return sqrt(ellipse.get_a()*ellipse.get_a()*sin(t)*sin(t)+ellipse.get_b()*ellipse.get_b()*cos(t)*cos(t)); |
109 |
|
|
} |
110 |
|
|
double ST_ELLIPSE::get_longueur(double t1,double t2,double precis) |
111 |
|
|
{ |
112 |
|
|
TPL_FONCTION1<double,ST_ELLIPSE,double> longueur_ellipse(*this,equation_longueur); |
113 |
|
|
return longueur_ellipse.integrer_gauss_2(t1,t2); |
114 |
|
|
} |
115 |
|
|
int ST_ELLIPSE::est_periodique(void) |
116 |
|
|
{ |
117 |
|
|
return 1; |
118 |
|
|
} |
119 |
|
|
double ST_ELLIPSE::get_periode(void) |
120 |
|
|
{ |
121 |
|
|
return 2.*M_PI; |
122 |
|
|
} |
123 |
|
|
|
124 |
|
|
void ST_ELLIPSE::initialiser(ST_GESTIONNAIRE *gest) |
125 |
|
|
{ |
126 |
|
|
ST_AXIS2_PLACEMENT_3D* axe=gest->lst_axis2_placement_3d.getid(id_axis2_placement_3d); |
127 |
|
|
ST_DIRECTION* dirz=gest->lst_direction.getid(axe->get_id_direction1()); |
128 |
|
|
ST_DIRECTION* dirx=gest->lst_direction.getid(axe->get_id_direction2()); |
129 |
|
|
ST_POINT* point=gest->lst_point.getid(axe->get_id_point()); |
130 |
|
|
double xyz[3]; |
131 |
|
|
point->evaluer(xyz); |
132 |
|
|
double *dirxyzz=dirz->get_direction(); |
133 |
|
|
double *dirxyzx=dirx->get_direction(); |
134 |
|
|
initialiser(xyz,dirxyzz,dirxyzx); |
135 |
|
|
} |
136 |
|
|
|
137 |
|
|
void ST_ELLIPSE::initialiser(double *xyz,double *dirz,double *dirx) |
138 |
|
|
{ |
139 |
|
|
origine.change_x(xyz[0]); |
140 |
|
|
origine.change_y(xyz[1]); |
141 |
|
|
origine.change_z(xyz[2]); |
142 |
|
|
OT_VECTEUR_3D z(dirz[0],dirz[1],dirz[2]); |
143 |
|
|
z.norme(); |
144 |
|
|
OT_VECTEUR_3D x(dirx[0],dirx[1],dirx[2]); |
145 |
|
|
x.norme(); |
146 |
|
|
OT_VECTEUR_3D y=z&x; |
147 |
|
|
repere.change_vecteur1(x); |
148 |
|
|
repere.change_vecteur2(y); |
149 |
|
|
repere.change_vecteur3(z); |
150 |
|
|
} |
151 |
|
|
|
152 |
|
|
int ST_ELLIPSE::get_type_geometrique(TPL_LISTE_ENTITE<double> ¶m) |
153 |
|
|
{ |
154 |
|
|
param.ajouter(origine.get_x()); |
155 |
|
|
param.ajouter(origine.get_y()); |
156 |
|
|
param.ajouter(origine.get_z()); |
157 |
|
|
param.ajouter(repere.get_vecteur1().get_x()); |
158 |
|
|
param.ajouter(repere.get_vecteur1().get_y()); |
159 |
|
|
param.ajouter(repere.get_vecteur1().get_z()); |
160 |
|
|
param.ajouter(repere.get_vecteur3().get_x()); |
161 |
|
|
param.ajouter(repere.get_vecteur3().get_y()); |
162 |
|
|
param.ajouter(repere.get_vecteur3().get_z()); |
163 |
|
|
param.ajouter(a); |
164 |
|
|
param.ajouter(b); |
165 |
francois |
1149 |
return GEOMETRIE::CONST::Co_ELLIPSE; |
166 |
francois |
283 |
} |
167 |
|
|
|
168 |
|
|
|
169 |
|
|
void ST_ELLIPSE::est_util(ST_GESTIONNAIRE* gest) |
170 |
|
|
{ |
171 |
|
|
util=true; |
172 |
|
|
gest->lst_axis2_placement_3d.getid(id_axis2_placement_3d)->est_util(gest); |
173 |
|
|
} |
174 |
|
|
|
175 |
|
|
|
176 |
|
|
void ST_ELLIPSE::get_param_NURBS(int& indx_premier_ptctr,TPL_LISTE_ENTITE<double> ¶m) |
177 |
|
|
{ |
178 |
|
|
|
179 |
|
|
|
180 |
|
|
double xyz[3]; |
181 |
|
|
param.ajouter(1); |
182 |
|
|
|
183 |
|
|
|
184 |
|
|
param.ajouter(4); |
185 |
|
|
param.ajouter(0); |
186 |
|
|
|
187 |
|
|
|
188 |
|
|
param.ajouter(7); |
189 |
|
|
param.ajouter(0); |
190 |
|
|
|
191 |
|
|
|
192 |
|
|
param.ajouter(0); |
193 |
|
|
param.ajouter(0); |
194 |
|
|
param.ajouter(0); |
195 |
|
|
param.ajouter(0.25); |
196 |
|
|
param.ajouter(0.5); |
197 |
|
|
param.ajouter(0.5); |
198 |
|
|
param.ajouter(0.75); |
199 |
|
|
param.ajouter(1); |
200 |
|
|
param.ajouter(1); |
201 |
|
|
param.ajouter(1); |
202 |
|
|
|
203 |
|
|
|
204 |
|
|
|
205 |
|
|
OT_VECTEUR_3D loc(a,0,0); |
206 |
|
|
OT_VECTEUR_3D glob=origine+repere*loc; |
207 |
|
|
|
208 |
|
|
xyz[0]=glob.get_x(); |
209 |
|
|
xyz[1]=glob.get_y(); |
210 |
|
|
xyz[2]=glob.get_z(); |
211 |
|
|
|
212 |
|
|
param.ajouter(xyz[0]); |
213 |
|
|
param.ajouter(xyz[1]); |
214 |
|
|
param.ajouter(xyz[2]); |
215 |
|
|
param.ajouter(1); |
216 |
|
|
|
217 |
|
|
|
218 |
|
|
loc.change_y(b); |
219 |
|
|
glob=origine+repere*loc; |
220 |
|
|
|
221 |
|
|
xyz[0]=glob.get_x(); |
222 |
|
|
xyz[1]=glob.get_y(); |
223 |
|
|
xyz[2]=glob.get_z(); |
224 |
|
|
|
225 |
|
|
param.ajouter(xyz[0]); |
226 |
|
|
param.ajouter(xyz[1]); |
227 |
|
|
param.ajouter(xyz[2]); |
228 |
|
|
param.ajouter(0.5); |
229 |
|
|
|
230 |
|
|
|
231 |
|
|
loc.change_x(-a); |
232 |
|
|
glob=origine+repere*loc; |
233 |
|
|
|
234 |
|
|
|
235 |
|
|
xyz[0]=glob.get_x(); |
236 |
|
|
xyz[1]=glob.get_y(); |
237 |
|
|
xyz[2]=glob.get_z(); |
238 |
|
|
|
239 |
|
|
param.ajouter(xyz[0]); |
240 |
|
|
param.ajouter(xyz[1]); |
241 |
|
|
param.ajouter(xyz[2]); |
242 |
|
|
param.ajouter(0.5); |
243 |
|
|
|
244 |
|
|
|
245 |
|
|
loc.change_y(0); |
246 |
|
|
|
247 |
|
|
glob=origine+repere*loc; |
248 |
|
|
|
249 |
|
|
xyz[0]=glob.get_x(); |
250 |
|
|
xyz[1]=glob.get_y(); |
251 |
|
|
xyz[2]=glob.get_z(); |
252 |
|
|
|
253 |
|
|
param.ajouter(xyz[0]); |
254 |
|
|
param.ajouter(xyz[1]); |
255 |
|
|
param.ajouter(xyz[2]); |
256 |
|
|
param.ajouter(1); |
257 |
|
|
|
258 |
|
|
|
259 |
|
|
|
260 |
|
|
|
261 |
|
|
loc.change_y(-b); |
262 |
|
|
|
263 |
|
|
glob=origine+repere*loc; |
264 |
|
|
|
265 |
|
|
xyz[0]=glob.get_x(); |
266 |
|
|
xyz[1]=glob.get_y(); |
267 |
|
|
xyz[2]=glob.get_z(); |
268 |
|
|
|
269 |
|
|
param.ajouter(xyz[0]); |
270 |
|
|
param.ajouter(xyz[1]); |
271 |
|
|
param.ajouter(xyz[2]); |
272 |
|
|
param.ajouter(0.5); |
273 |
|
|
|
274 |
|
|
|
275 |
|
|
loc.change_x(a); |
276 |
|
|
|
277 |
|
|
glob=origine+repere*loc; |
278 |
|
|
|
279 |
|
|
xyz[0]=glob.get_x(); |
280 |
|
|
xyz[1]=glob.get_y(); |
281 |
|
|
xyz[2]=glob.get_z(); |
282 |
|
|
|
283 |
|
|
param.ajouter(xyz[0]); |
284 |
|
|
param.ajouter(xyz[1]); |
285 |
|
|
param.ajouter(xyz[2]); |
286 |
|
|
param.ajouter(0.5); |
287 |
|
|
|
288 |
|
|
|
289 |
|
|
loc.change_y(0); |
290 |
|
|
|
291 |
|
|
glob=origine+repere*loc; |
292 |
|
|
|
293 |
|
|
xyz[0]=glob.get_x(); |
294 |
|
|
xyz[1]=glob.get_y(); |
295 |
|
|
xyz[2]=glob.get_z(); |
296 |
|
|
|
297 |
|
|
param.ajouter(xyz[0]); |
298 |
|
|
param.ajouter(xyz[1]); |
299 |
|
|
param.ajouter(xyz[2]); |
300 |
|
|
param.ajouter(1); |
301 |
|
|
|
302 |
|
|
indx_premier_ptctr=15; |
303 |
|
|
|
304 |
|
|
} |