1 |
francois |
283 |
//------------------------------------------------------------ |
2 |
|
|
//------------------------------------------------------------ |
3 |
|
|
// MAGiC |
4 |
|
|
// Jean Christophe Cuilli�re et Vincent FRANCOIS |
5 |
|
|
// D�partement de G�nie M�canique - UQTR |
6 |
|
|
//------------------------------------------------------------ |
7 |
|
|
// Le projet MAGIC est un projet de recherche du d�partement |
8 |
|
|
// de g�nie m�canique de l'Universit� du Qu�bec � |
9 |
|
|
// Trois Rivi�res |
10 |
|
|
// Les librairies ne peuvent �tre utilis�es sans l'accord |
11 |
|
|
// des auteurs (contact : francois@uqtr.ca) |
12 |
|
|
//------------------------------------------------------------ |
13 |
|
|
//------------------------------------------------------------ |
14 |
|
|
// |
15 |
|
|
// stellipse.cpp |
16 |
|
|
// |
17 |
|
|
//------------------------------------------------------------ |
18 |
|
|
//------------------------------------------------------------ |
19 |
|
|
// COPYRIGHT 2000 |
20 |
|
|
// Version du 02/03/2006 � 11H24 |
21 |
|
|
//------------------------------------------------------------ |
22 |
|
|
//------------------------------------------------------------ |
23 |
|
|
|
24 |
|
|
|
25 |
|
|
#include "gestionversion.h" |
26 |
|
|
|
27 |
|
|
#include "stellipse.h" |
28 |
|
|
#include "st_gestionnaire.h" |
29 |
|
|
#include "tpl_fonction.h" |
30 |
|
|
#include "constantegeo.h" |
31 |
|
|
|
32 |
|
|
#include <math.h> |
33 |
|
|
|
34 |
|
|
|
35 |
|
|
|
36 |
|
|
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) |
37 |
|
|
{ |
38 |
|
|
} |
39 |
|
|
|
40 |
|
|
ST_ELLIPSE::ST_ELLIPSE(double *xyz,double *dirz,double *dirx,double a,double b):ST_COURBE(),a(a),b(b) |
41 |
|
|
{ |
42 |
|
|
initialiser(xyz,dirz,dirx); |
43 |
|
|
} |
44 |
|
|
|
45 |
|
|
|
46 |
|
|
long ST_ELLIPSE::get_id_axis2_placement_3d(void) |
47 |
|
|
{ |
48 |
|
|
return id_axis2_placement_3d; |
49 |
|
|
} |
50 |
|
|
double ST_ELLIPSE::get_a(void) |
51 |
|
|
{ |
52 |
|
|
return a; |
53 |
|
|
} |
54 |
|
|
double ST_ELLIPSE::get_b(void) |
55 |
|
|
{ |
56 |
|
|
return b; |
57 |
|
|
} |
58 |
|
|
void ST_ELLIPSE::evaluer(double t,double *xyz) |
59 |
|
|
{ |
60 |
|
|
OT_VECTEUR_3D local(a*cos(t),b*sin(t),0.); |
61 |
|
|
OT_VECTEUR_3D global=origine+repere*local; |
62 |
|
|
xyz[0]=global.get_x(); |
63 |
|
|
xyz[1]=global.get_y(); |
64 |
|
|
xyz[2]=global.get_z(); |
65 |
|
|
} |
66 |
|
|
void ST_ELLIPSE::deriver(double t,double *dxyz) |
67 |
|
|
{ |
68 |
|
|
OT_VECTEUR_3D local(-a*sin(t),b*cos(t),0.); |
69 |
|
|
OT_VECTEUR_3D global=repere*local; |
70 |
|
|
dxyz[0]=global.get_x(); |
71 |
|
|
dxyz[1]=global.get_y(); |
72 |
|
|
dxyz[2]=global.get_z(); |
73 |
|
|
} |
74 |
|
|
void ST_ELLIPSE::deriver_seconde(double t,double *ddxyz,double* dxyz ,double* xyz ) |
75 |
|
|
{ |
76 |
|
|
OT_VECTEUR_3D local(-a*cos(t),-b*sin(t),0.); |
77 |
|
|
OT_VECTEUR_3D global=repere*local; |
78 |
|
|
ddxyz[0]=global.get_x(); |
79 |
|
|
ddxyz[1]=global.get_y(); |
80 |
|
|
ddxyz[2]=global.get_z(); |
81 |
|
|
if (dxyz!=NULL) deriver(t,dxyz); |
82 |
|
|
if (xyz!=NULL) evaluer(t,xyz); |
83 |
|
|
} |
84 |
|
|
void ST_ELLIPSE::inverser(double& t,double *xyz,double precision) |
85 |
|
|
{ |
86 |
|
|
double sign; |
87 |
|
|
double valeur; |
88 |
|
|
OT_VECTEUR_3D global(xyz[0],xyz[1],xyz[2]); |
89 |
|
|
OT_MATRICE_3D transpose_repere; |
90 |
|
|
repere.transpose(transpose_repere); |
91 |
|
|
OT_VECTEUR_3D vecteur=transpose_repere*(global-origine); |
92 |
|
|
valeur=vecteur.get_x()/a; |
93 |
|
|
if (valeur>1) valeur=1; |
94 |
|
|
if (valeur<-1) valeur=-1; |
95 |
|
|
t=acos(valeur); |
96 |
|
|
sign=vecteur.get_y()/b; |
97 |
|
|
if (sign<-0.000001) t= 2.*M_PI-t; |
98 |
|
|
} |
99 |
|
|
double ST_ELLIPSE::get_tmin() |
100 |
|
|
{ |
101 |
|
|
return 0.; |
102 |
|
|
} |
103 |
|
|
double ST_ELLIPSE::get_tmax() |
104 |
|
|
{ |
105 |
|
|
return 2.*M_PI; |
106 |
|
|
} |
107 |
|
|
|
108 |
|
|
double equation_longueur(ST_ELLIPSE& ellipse,double t) |
109 |
|
|
{ |
110 |
|
|
return sqrt(ellipse.get_a()*ellipse.get_a()*sin(t)*sin(t)+ellipse.get_b()*ellipse.get_b()*cos(t)*cos(t)); |
111 |
|
|
} |
112 |
|
|
double ST_ELLIPSE::get_longueur(double t1,double t2,double precis) |
113 |
|
|
{ |
114 |
|
|
TPL_FONCTION1<double,ST_ELLIPSE,double> longueur_ellipse(*this,equation_longueur); |
115 |
|
|
return longueur_ellipse.integrer_gauss_2(t1,t2); |
116 |
|
|
} |
117 |
|
|
int ST_ELLIPSE::est_periodique(void) |
118 |
|
|
{ |
119 |
|
|
return 1; |
120 |
|
|
} |
121 |
|
|
double ST_ELLIPSE::get_periode(void) |
122 |
|
|
{ |
123 |
|
|
return 2.*M_PI; |
124 |
|
|
} |
125 |
|
|
|
126 |
|
|
void ST_ELLIPSE::initialiser(ST_GESTIONNAIRE *gest) |
127 |
|
|
{ |
128 |
|
|
ST_AXIS2_PLACEMENT_3D* axe=gest->lst_axis2_placement_3d.getid(id_axis2_placement_3d); |
129 |
|
|
ST_DIRECTION* dirz=gest->lst_direction.getid(axe->get_id_direction1()); |
130 |
|
|
ST_DIRECTION* dirx=gest->lst_direction.getid(axe->get_id_direction2()); |
131 |
|
|
ST_POINT* point=gest->lst_point.getid(axe->get_id_point()); |
132 |
|
|
double xyz[3]; |
133 |
|
|
point->evaluer(xyz); |
134 |
|
|
double *dirxyzz=dirz->get_direction(); |
135 |
|
|
double *dirxyzx=dirx->get_direction(); |
136 |
|
|
initialiser(xyz,dirxyzz,dirxyzx); |
137 |
|
|
} |
138 |
|
|
|
139 |
|
|
void ST_ELLIPSE::initialiser(double *xyz,double *dirz,double *dirx) |
140 |
|
|
{ |
141 |
|
|
origine.change_x(xyz[0]); |
142 |
|
|
origine.change_y(xyz[1]); |
143 |
|
|
origine.change_z(xyz[2]); |
144 |
|
|
OT_VECTEUR_3D z(dirz[0],dirz[1],dirz[2]); |
145 |
|
|
z.norme(); |
146 |
|
|
OT_VECTEUR_3D x(dirx[0],dirx[1],dirx[2]); |
147 |
|
|
x.norme(); |
148 |
|
|
OT_VECTEUR_3D y=z&x; |
149 |
|
|
repere.change_vecteur1(x); |
150 |
|
|
repere.change_vecteur2(y); |
151 |
|
|
repere.change_vecteur3(z); |
152 |
|
|
} |
153 |
|
|
|
154 |
|
|
int ST_ELLIPSE::get_type_geometrique(TPL_LISTE_ENTITE<double> ¶m) |
155 |
|
|
{ |
156 |
|
|
param.ajouter(origine.get_x()); |
157 |
|
|
param.ajouter(origine.get_y()); |
158 |
|
|
param.ajouter(origine.get_z()); |
159 |
|
|
param.ajouter(repere.get_vecteur1().get_x()); |
160 |
|
|
param.ajouter(repere.get_vecteur1().get_y()); |
161 |
|
|
param.ajouter(repere.get_vecteur1().get_z()); |
162 |
|
|
param.ajouter(repere.get_vecteur3().get_x()); |
163 |
|
|
param.ajouter(repere.get_vecteur3().get_y()); |
164 |
|
|
param.ajouter(repere.get_vecteur3().get_z()); |
165 |
|
|
param.ajouter(a); |
166 |
|
|
param.ajouter(b); |
167 |
|
|
return MGCo_ELLIPSE; |
168 |
|
|
} |
169 |
|
|
|
170 |
|
|
|
171 |
|
|
void ST_ELLIPSE::est_util(ST_GESTIONNAIRE* gest) |
172 |
|
|
{ |
173 |
|
|
util=true; |
174 |
|
|
gest->lst_axis2_placement_3d.getid(id_axis2_placement_3d)->est_util(gest); |
175 |
|
|
} |
176 |
|
|
|
177 |
|
|
|
178 |
|
|
void ST_ELLIPSE::get_param_NURBS(int& indx_premier_ptctr,TPL_LISTE_ENTITE<double> ¶m) |
179 |
|
|
{ |
180 |
|
|
|
181 |
|
|
|
182 |
|
|
double xyz[3]; |
183 |
|
|
// The first parameter indicate the code access |
184 |
|
|
param.ajouter(1); |
185 |
|
|
|
186 |
|
|
// The follewing two parameters of the list indicate the orders of the net points |
187 |
|
|
|
188 |
|
|
param.ajouter(4); |
189 |
|
|
param.ajouter(0); |
190 |
|
|
|
191 |
|
|
// The follewing two parameters indicate the number of rows and colons of the control points |
192 |
|
|
// respectively to the two parameters directions |
193 |
|
|
|
194 |
|
|
param.ajouter(7); |
195 |
|
|
param.ajouter(0); |
196 |
|
|
|
197 |
|
|
// this present the knot vector in the u-direction |
198 |
|
|
|
199 |
|
|
param.ajouter(0); |
200 |
|
|
param.ajouter(0); |
201 |
|
|
param.ajouter(0); |
202 |
|
|
param.ajouter(0.25); |
203 |
|
|
param.ajouter(0.5); |
204 |
|
|
param.ajouter(0.5); |
205 |
|
|
param.ajouter(0.75); |
206 |
|
|
param.ajouter(1); |
207 |
|
|
param.ajouter(1); |
208 |
|
|
param.ajouter(1); |
209 |
|
|
|
210 |
|
|
|
211 |
|
|
//the first control point |
212 |
|
|
|
213 |
|
|
OT_VECTEUR_3D loc(a,0,0); |
214 |
|
|
OT_VECTEUR_3D glob=origine+repere*loc; |
215 |
|
|
|
216 |
|
|
xyz[0]=glob.get_x(); |
217 |
|
|
xyz[1]=glob.get_y(); |
218 |
|
|
xyz[2]=glob.get_z(); |
219 |
|
|
|
220 |
|
|
param.ajouter(xyz[0]); |
221 |
|
|
param.ajouter(xyz[1]); |
222 |
|
|
param.ajouter(xyz[2]); |
223 |
|
|
param.ajouter(1); |
224 |
|
|
|
225 |
|
|
// the second control point have such local cordinate (rayon,rayon) |
226 |
|
|
|
227 |
|
|
loc.change_y(b); |
228 |
|
|
glob=origine+repere*loc; |
229 |
|
|
|
230 |
|
|
xyz[0]=glob.get_x(); |
231 |
|
|
xyz[1]=glob.get_y(); |
232 |
|
|
xyz[2]=glob.get_z(); |
233 |
|
|
|
234 |
|
|
param.ajouter(xyz[0]); |
235 |
|
|
param.ajouter(xyz[1]); |
236 |
|
|
param.ajouter(xyz[2]); |
237 |
|
|
param.ajouter(0.5); |
238 |
|
|
|
239 |
|
|
//the third control point have such local cordinate (-rayon,rayon) |
240 |
|
|
|
241 |
|
|
loc.change_x(-a); |
242 |
|
|
glob=origine+repere*loc; |
243 |
|
|
|
244 |
|
|
|
245 |
|
|
xyz[0]=glob.get_x(); |
246 |
|
|
xyz[1]=glob.get_y(); |
247 |
|
|
xyz[2]=glob.get_z(); |
248 |
|
|
|
249 |
|
|
param.ajouter(xyz[0]); |
250 |
|
|
param.ajouter(xyz[1]); |
251 |
|
|
param.ajouter(xyz[2]); |
252 |
|
|
param.ajouter(0.5); |
253 |
|
|
|
254 |
|
|
//The forth point have the local cordinate at(-rayon,rayon) |
255 |
|
|
|
256 |
|
|
loc.change_y(0); |
257 |
|
|
|
258 |
|
|
glob=origine+repere*loc; |
259 |
|
|
|
260 |
|
|
xyz[0]=glob.get_x(); |
261 |
|
|
xyz[1]=glob.get_y(); |
262 |
|
|
xyz[2]=glob.get_z(); |
263 |
|
|
|
264 |
|
|
param.ajouter(xyz[0]); |
265 |
|
|
param.ajouter(xyz[1]); |
266 |
|
|
param.ajouter(xyz[2]); |
267 |
|
|
param.ajouter(1); |
268 |
|
|
|
269 |
|
|
|
270 |
|
|
//the fifth control point have the corfinate in the local cordinate (-rayon,-rayon) |
271 |
|
|
|
272 |
|
|
|
273 |
|
|
loc.change_y(-b); |
274 |
|
|
|
275 |
|
|
glob=origine+repere*loc; |
276 |
|
|
|
277 |
|
|
xyz[0]=glob.get_x(); |
278 |
|
|
xyz[1]=glob.get_y(); |
279 |
|
|
xyz[2]=glob.get_z(); |
280 |
|
|
|
281 |
|
|
param.ajouter(xyz[0]); |
282 |
|
|
param.ajouter(xyz[1]); |
283 |
|
|
param.ajouter(xyz[2]); |
284 |
|
|
param.ajouter(0.5); |
285 |
|
|
|
286 |
|
|
//The sixth control point have the cordiante in the local coordinate (rayon,-rayon) |
287 |
|
|
|
288 |
|
|
loc.change_x(a); |
289 |
|
|
|
290 |
|
|
glob=origine+repere*loc; |
291 |
|
|
|
292 |
|
|
xyz[0]=glob.get_x(); |
293 |
|
|
xyz[1]=glob.get_y(); |
294 |
|
|
xyz[2]=glob.get_z(); |
295 |
|
|
|
296 |
|
|
param.ajouter(xyz[0]); |
297 |
|
|
param.ajouter(xyz[1]); |
298 |
|
|
param.ajouter(xyz[2]); |
299 |
|
|
param.ajouter(0.5); |
300 |
|
|
|
301 |
|
|
//The last control point have the same local cordinate with rhe first control point (rayon, 0) |
302 |
|
|
|
303 |
|
|
loc.change_y(0); |
304 |
|
|
|
305 |
|
|
glob=origine+repere*loc; |
306 |
|
|
|
307 |
|
|
xyz[0]=glob.get_x(); |
308 |
|
|
xyz[1]=glob.get_y(); |
309 |
|
|
xyz[2]=glob.get_z(); |
310 |
|
|
|
311 |
|
|
param.ajouter(xyz[0]); |
312 |
|
|
param.ajouter(xyz[1]); |
313 |
|
|
param.ajouter(xyz[2]); |
314 |
|
|
param.ajouter(1); |
315 |
|
|
|
316 |
|
|
indx_premier_ptctr=15; |
317 |
|
|
|
318 |
|
|
} |