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 |
//####// sat_cone.cpp |
15 |
//####// |
16 |
//####//------------------------------------------------------------ |
17 |
//####//------------------------------------------------------------ |
18 |
//####// COPYRIGHT 2000-2024 |
19 |
//####// jeu 13 jun 2024 11:54:00 EDT |
20 |
//####//------------------------------------------------------------ |
21 |
//####//------------------------------------------------------------ |
22 |
|
23 |
|
24 |
#include <math.h> |
25 |
#include "constantegeo.h" |
26 |
#include "sat_cone.h" |
27 |
|
28 |
#include "ot_mathematique.h" |
29 |
|
30 |
|
31 |
SAT_CONE::SAT_CONE(unsigned long num):SAT_SURFACE(num) |
32 |
{ |
33 |
} |
34 |
|
35 |
SAT_CONE::SAT_CONE():SAT_SURFACE() |
36 |
{ |
37 |
} |
38 |
|
39 |
SAT_CONE::~SAT_CONE() |
40 |
{ |
41 |
} |
42 |
|
43 |
|
44 |
void SAT_CONE::calcule_parametre(void) |
45 |
{ |
46 |
a=sqrt(major[0]*major[0]+major[1]*major[1]+major[2]*major[2]); |
47 |
OT_VECTEUR_3D u(major); |
48 |
OT_VECTEUR_3D w(normal); |
49 |
OT_VECTEUR_3D v=w&u; |
50 |
minor[0]=v.get_x(); |
51 |
minor[1]=v.get_y(); |
52 |
minor[2]=v.get_z(); |
53 |
u.norme(); |
54 |
w.norme(); |
55 |
v.norme(); |
56 |
major[0]=u.get_x(); |
57 |
major[1]=u.get_y(); |
58 |
major[2]=u.get_z(); |
59 |
minor[0]=v.get_x(); |
60 |
minor[1]=v.get_y(); |
61 |
minor[2]=v.get_z(); |
62 |
normal[0]=w.get_x(); |
63 |
normal[1]=w.get_y(); |
64 |
normal[2]=w.get_z(); |
65 |
if (cosalpha<0.) un=-1.0; |
66 |
else un=1.0; |
67 |
} |
68 |
|
69 |
|
70 |
void SAT_CONE::evaluer(double *uv,double *xyz) |
71 |
{ |
72 |
double xtmp,ytmp,ztmp; |
73 |
xtmp=a*(1.+un*uv[1]*sinalpha/cosalpha)*cos(uv[0]); |
74 |
ytmp=a*ratio*(1.+un*uv[1]*sinalpha/cosalpha)*sin(uv[0]); |
75 |
ztmp=un*a*uv[1]; |
76 |
xyz[0]=center[0]+major[0]*xtmp+minor[0]*ytmp+normal[0]*ztmp; |
77 |
xyz[1]=center[1]+major[1]*xtmp+minor[1]*ytmp+normal[1]*ztmp; |
78 |
xyz[2]=center[2]+major[2]*xtmp+minor[2]*ytmp+normal[2]*ztmp; |
79 |
} |
80 |
|
81 |
void SAT_CONE::deriver(double *uv,double *xyzdu, double *xyzdv) |
82 |
{ |
83 |
double xtmp,ytmp,ztmp; |
84 |
xtmp=-a*(1.+un*uv[1]*sinalpha/cosalpha)*sin(uv[0]); |
85 |
ytmp=a*ratio*(1.+un*uv[1]*sinalpha/cosalpha)*cos(uv[0]); |
86 |
ztmp=0.; |
87 |
xyzdu[0]=major[0]*xtmp+minor[0]*ytmp+normal[0]*ztmp; |
88 |
xyzdu[1]=major[1]*xtmp+minor[1]*ytmp+normal[1]*ztmp; |
89 |
xyzdu[2]=major[2]*xtmp+minor[2]*ytmp+normal[2]*ztmp; |
90 |
xtmp=un*a*sinalpha/cosalpha*cos(uv[0]); |
91 |
ytmp=un*a*ratio*sinalpha/cosalpha*sin(uv[0]); |
92 |
ztmp=un*a; |
93 |
xyzdv[0]=major[0]*xtmp+minor[0]*ytmp+normal[0]*ztmp; |
94 |
xyzdv[1]=major[1]*xtmp+minor[1]*ytmp+normal[1]*ztmp; |
95 |
xyzdv[2]=major[2]*xtmp+minor[2]*ytmp+normal[2]*ztmp; |
96 |
} |
97 |
|
98 |
void SAT_CONE::deriver_seconde(double *uv,double* xyzduu,double* xyzduv,double* xyzdvv,double *xyz , double *xyzdu, double *xyzdv) |
99 |
{ |
100 |
double xtmp,ytmp,ztmp; |
101 |
xtmp=-a*(1.+un*uv[1]*sinalpha/cosalpha)*cos(uv[0]); |
102 |
ytmp=-a*ratio*(1.+un*uv[1]*sinalpha/cosalpha)*sin(uv[0]); |
103 |
ztmp=0.; |
104 |
xyzduu[0]=major[0]*xtmp+minor[0]*ytmp+normal[0]*ztmp; |
105 |
xyzduu[1]=major[1]*xtmp+minor[1]*ytmp+normal[1]*ztmp; |
106 |
xyzduu[2]=major[2]*xtmp+minor[2]*ytmp+normal[2]*ztmp; |
107 |
xtmp=(-a*un*sinalpha/cosalpha*sin(uv[0])); |
108 |
ytmp=a*un*ratio*sinalpha/cosalpha*cos(uv[0]); |
109 |
ztmp=0.; |
110 |
xyzduv[0]=major[0]*xtmp+minor[0]*ytmp+normal[0]*ztmp; |
111 |
xyzduv[1]=major[1]*xtmp+minor[1]*ytmp+normal[1]*ztmp; |
112 |
xyzduv[2]=major[2]*xtmp+minor[2]*ytmp+normal[2]*ztmp; |
113 |
xyzdvv[0]=0.; |
114 |
xyzdvv[1]=0.; |
115 |
xyzdvv[2]=0.; |
116 |
if ((xyzdu!=NULL) && (xyzdv!=NULL ) ) deriver(uv,xyzdu,xyzdv); |
117 |
if (xyz!=NULL) evaluer(uv,xyz); |
118 |
} |
119 |
|
120 |
void SAT_CONE::inverser(double *uv,double *xyz,double precision) |
121 |
{ |
122 |
double xtmp,ytmp,ztmp; |
123 |
xtmp=major[0]*(xyz[0]-center[0])+major[1]*(xyz[1]-center[1])+major[2]*(xyz[2]-center[2]); |
124 |
ytmp=minor[0]*(xyz[0]-center[0])+minor[1]*(xyz[1]-center[1])+minor[2]*(xyz[2]-center[2]); |
125 |
ztmp=normal[0]*(xyz[0]-center[0])+normal[1]*(xyz[1]-center[1])+normal[2]*(xyz[2]-center[2]); |
126 |
uv[1]=un*ztmp/a; |
127 |
double cs=xtmp/(a*(1.+un*uv[1]*sinalpha/cosalpha)); |
128 |
double sn=ytmp/(a*ratio*(1.+un*uv[1]*sinalpha/cosalpha)); |
129 |
if (cs>1) cs=1.; |
130 |
if (cs<(-1)) cs=(-1.); |
131 |
double angle=acos((double)cs); |
132 |
if (sn<(-0.0001)) angle=(-angle); |
133 |
if (angle<0) angle=angle+2*M_PI; |
134 |
uv[0]=angle; |
135 |
} |
136 |
|
137 |
int SAT_CONE::est_periodique_u(void) |
138 |
{ |
139 |
return 1; |
140 |
} |
141 |
|
142 |
int SAT_CONE::est_periodique_v(void) |
143 |
{ |
144 |
return 0; |
145 |
} |
146 |
|
147 |
double SAT_CONE::get_periode_u(void) |
148 |
{ |
149 |
return 2*M_PI; |
150 |
} |
151 |
|
152 |
double SAT_CONE::get_periode_v(void) |
153 |
{ |
154 |
return 0.; |
155 |
} |
156 |
|
157 |
|
158 |
double SAT_CONE::get_umin(void) |
159 |
{ |
160 |
return 0; |
161 |
} |
162 |
|
163 |
double SAT_CONE::get_umax(void) |
164 |
{ |
165 |
return 2*M_PI; |
166 |
} |
167 |
|
168 |
double SAT_CONE::get_vmin(void) |
169 |
{ |
170 |
return -1e300; |
171 |
} |
172 |
|
173 |
double SAT_CONE::get_vmax(void) |
174 |
{ |
175 |
return 1e300; |
176 |
} |
177 |
|
178 |
|
179 |
int SAT_CONE::get_type_geometrique(TPL_LISTE_ENTITE<double> ¶m) |
180 |
{ |
181 |
param.ajouter(center[0]); |
182 |
param.ajouter(center[1]); |
183 |
param.ajouter(center[2]); |
184 |
param.ajouter(major[0]); |
185 |
param.ajouter(major[1]); |
186 |
param.ajouter(major[2]); |
187 |
param.ajouter(normal[0]); |
188 |
param.ajouter(normal[1]); |
189 |
param.ajouter(normal[2]); |
190 |
param.ajouter(a); |
191 |
param.ajouter(a*ratio); |
192 |
if (fabs(sinalpha<0.00000001)) |
193 |
return GEOMETRIE::CONST::Co_CYLINDRE; |
194 |
param.ajouter(cosalpha); |
195 |
param.ajouter(sinalpha); |
196 |
return GEOMETRIE::CONST::Co_CONE; |
197 |
} |
198 |
|
199 |
|
200 |
|
201 |
|
202 |
|
203 |
|
204 |
|
205 |
|
206 |
void SAT_CONE::get_param_NURBS(int& indx_premier_ptctr,TPL_LISTE_ENTITE<double> ¶m) |
207 |
{ |
208 |
double uv[2]; |
209 |
double xyz[3]; |
210 |
|
211 |
param.ajouter(2); |
212 |
|
213 |
|
214 |
|
215 |
|
216 |
double xtmp,ytmp,ztmp; |
217 |
|
218 |
|
219 |
|
220 |
|
221 |
if (sinalpha==0) |
222 |
{ |
223 |
|
224 |
param.ajouter(4); |
225 |
param.ajouter(2); |
226 |
|
227 |
|
228 |
param.ajouter(7); |
229 |
param.ajouter(2); |
230 |
|
231 |
|
232 |
param.ajouter(0); |
233 |
param.ajouter(0); |
234 |
param.ajouter(0); |
235 |
param.ajouter(0.25); |
236 |
param.ajouter(0.5); |
237 |
param.ajouter(0.5); |
238 |
param.ajouter(0.75); |
239 |
param.ajouter(1); |
240 |
param.ajouter(1); |
241 |
param.ajouter(1); |
242 |
|
243 |
|
244 |
param.ajouter(0); |
245 |
param.ajouter(0); |
246 |
param.ajouter(1); |
247 |
param.ajouter(1); |
248 |
|
249 |
|
250 |
for (int j=0;j<2;j++) |
251 |
{ |
252 |
|
253 |
double z_inf=10e6; |
254 |
if (j==0) |
255 |
z_inf=-z_inf; |
256 |
if (j==1) |
257 |
z_inf=z_inf; |
258 |
|
259 |
|
260 |
|
261 |
xtmp=a; |
262 |
ytmp=0; |
263 |
ztmp=un*a*z_inf; |
264 |
|
265 |
xyz[0]=center[0]+major[0]*xtmp+minor[0]*ytmp+normal[0]*ztmp; |
266 |
xyz[1]=center[1]+major[1]*xtmp+minor[1]*ytmp+normal[1]*ztmp; |
267 |
xyz[2]=center[2]+major[2]*xtmp+minor[2]*ytmp+normal[2]*ztmp; |
268 |
|
269 |
|
270 |
|
271 |
param.ajouter(xyz[0]); |
272 |
param.ajouter(xyz[1]); |
273 |
param.ajouter(xyz[2]); |
274 |
param.ajouter(1); |
275 |
|
276 |
|
277 |
ytmp=a; |
278 |
|
279 |
|
280 |
xyz[0]=center[0]+major[0]*xtmp+minor[0]*ytmp+normal[0]*ztmp; |
281 |
xyz[1]=center[1]+major[1]*xtmp+minor[1]*ytmp+normal[1]*ztmp; |
282 |
xyz[2]=center[2]+major[2]*xtmp+minor[2]*ytmp+normal[2]*ztmp; |
283 |
|
284 |
param.ajouter(xyz[0]); |
285 |
param.ajouter(xyz[1]); |
286 |
param.ajouter(xyz[2]); |
287 |
param.ajouter(0.5); |
288 |
|
289 |
|
290 |
|
291 |
xtmp=-a; |
292 |
|
293 |
xyz[0]=center[0]+major[0]*xtmp+minor[0]*ytmp+normal[0]*ztmp; |
294 |
xyz[1]=center[1]+major[1]*xtmp+minor[1]*ytmp+normal[1]*ztmp; |
295 |
xyz[2]=center[2]+major[2]*xtmp+minor[2]*ytmp+normal[2]*ztmp; |
296 |
|
297 |
param.ajouter(xyz[0]); |
298 |
param.ajouter(xyz[1]); |
299 |
param.ajouter(xyz[2]); |
300 |
param.ajouter(0.5); |
301 |
|
302 |
|
303 |
ytmp=0; |
304 |
|
305 |
|
306 |
xyz[0]=center[0]+major[0]*xtmp+minor[0]*ytmp+normal[0]*ztmp; |
307 |
xyz[1]=center[1]+major[1]*xtmp+minor[1]*ytmp+normal[1]*ztmp; |
308 |
xyz[2]=center[2]+major[2]*xtmp+minor[2]*ytmp+normal[2]*ztmp; |
309 |
|
310 |
param.ajouter(xyz[0]); |
311 |
param.ajouter(xyz[1]); |
312 |
param.ajouter(xyz[2]); |
313 |
param.ajouter(1); |
314 |
|
315 |
|
316 |
|
317 |
|
318 |
ytmp=-a; |
319 |
|
320 |
|
321 |
xyz[0]=center[0]+major[0]*xtmp+minor[0]*ytmp+normal[0]*ztmp; |
322 |
xyz[1]=center[1]+major[1]*xtmp+minor[1]*ytmp+normal[1]*ztmp; |
323 |
xyz[2]=center[2]+major[2]*xtmp+minor[2]*ytmp+normal[2]*ztmp; |
324 |
|
325 |
param.ajouter(xyz[0]); |
326 |
param.ajouter(xyz[1]); |
327 |
param.ajouter(xyz[2]); |
328 |
param.ajouter(0.5); |
329 |
|
330 |
|
331 |
|
332 |
xtmp=a; |
333 |
|
334 |
|
335 |
xyz[0]=center[0]+major[0]*xtmp+minor[0]*ytmp+normal[0]*ztmp; |
336 |
xyz[1]=center[1]+major[1]*xtmp+minor[1]*ytmp+normal[1]*ztmp; |
337 |
xyz[2]=center[2]+major[2]*xtmp+minor[2]*ytmp+normal[2]*ztmp; |
338 |
|
339 |
|
340 |
param.ajouter(xyz[0]); |
341 |
param.ajouter(xyz[1]); |
342 |
param.ajouter(xyz[2]); |
343 |
param.ajouter(0.5); |
344 |
|
345 |
|
346 |
|
347 |
ytmp=0; |
348 |
|
349 |
xyz[0]=center[0]+major[0]*xtmp+minor[0]*ytmp+normal[0]*ztmp; |
350 |
xyz[1]=center[1]+major[1]*xtmp+minor[1]*ytmp+normal[1]*ztmp; |
351 |
xyz[2]=center[2]+major[2]*xtmp+minor[2]*ytmp+normal[2]*ztmp; |
352 |
|
353 |
param.ajouter(xyz[0]); |
354 |
param.ajouter(xyz[1]); |
355 |
param.ajouter(xyz[2]); |
356 |
param.ajouter(1); |
357 |
} |
358 |
|
359 |
} |
360 |
|
361 |
|
362 |
if (sinalpha!=0) |
363 |
{ |
364 |
param.ajouter(2); |
365 |
param.ajouter(4); |
366 |
|
367 |
|
368 |
param.ajouter(2); |
369 |
param.ajouter(7); |
370 |
|
371 |
param.ajouter(0); |
372 |
param.ajouter(0); |
373 |
param.ajouter(1); |
374 |
param.ajouter(1); |
375 |
|
376 |
param.ajouter(0); |
377 |
param.ajouter(0); |
378 |
param.ajouter(0); |
379 |
param.ajouter(0.25); |
380 |
param.ajouter(0.5); |
381 |
param.ajouter(0.5); |
382 |
param.ajouter(0.75); |
383 |
param.ajouter(1); |
384 |
param.ajouter(1); |
385 |
param.ajouter(1); |
386 |
|
387 |
|
388 |
|
389 |
xtmp=0; |
390 |
ytmp=0; |
391 |
double z_sommet_cone= un*a*sinalpha/cosalpha ; |
392 |
|
393 |
double x_som=center[0]+major[0]*xtmp+minor[0]*ytmp+normal[0]*z_sommet_cone; |
394 |
double y_som=center[1]+major[1]*xtmp+minor[1]*ytmp+normal[1]*z_sommet_cone; |
395 |
double z_som=center[2]+major[2]*xtmp+minor[2]*ytmp+normal[2]*z_sommet_cone; |
396 |
|
397 |
|
398 |
ztmp=(10e6-a)/(un*sinalpha/cosalpha); |
399 |
double r= ztmp*(sinalpha/cosalpha); |
400 |
|
401 |
|
402 |
xtmp=r; |
403 |
ytmp=0; |
404 |
|
405 |
xyz[0]=center[0]+major[0]*xtmp+minor[0]*ytmp+normal[0]*ztmp; |
406 |
xyz[1]=center[1]+major[1]*xtmp+minor[1]*ytmp+normal[1]*ztmp; |
407 |
xyz[2]=center[2]+major[2]*xtmp+minor[2]*ytmp+normal[2]*ztmp; |
408 |
|
409 |
param.ajouter(xyz[0]); |
410 |
param.ajouter(xyz[1]); |
411 |
param.ajouter(xyz[2]); |
412 |
param.ajouter(1); |
413 |
|
414 |
param.ajouter(x_som); |
415 |
param.ajouter(y_som); |
416 |
param.ajouter(z_som); |
417 |
param.ajouter(1); |
418 |
ytmp=r; |
419 |
|
420 |
xyz[0]=center[0]+major[0]*xtmp+minor[0]*ytmp+normal[0]*ztmp; |
421 |
xyz[1]=center[1]+major[1]*xtmp+minor[1]*ytmp+normal[1]*ztmp; |
422 |
xyz[2]=center[2]+major[2]*xtmp+minor[2]*ytmp+normal[2]*ztmp; |
423 |
|
424 |
param.ajouter(xyz[0]); |
425 |
param.ajouter(xyz[1]); |
426 |
param.ajouter(xyz[2]); |
427 |
param.ajouter(0.5); |
428 |
|
429 |
param.ajouter(x_som); |
430 |
param.ajouter(y_som); |
431 |
param.ajouter(z_som); |
432 |
param.ajouter(0.5); |
433 |
xtmp=-r; |
434 |
|
435 |
xyz[0]=center[0]+major[0]*xtmp+minor[0]*ytmp+normal[0]*ztmp; |
436 |
xyz[1]=center[1]+major[1]*xtmp+minor[1]*ytmp+normal[1]*ztmp; |
437 |
xyz[2]=center[2]+major[2]*xtmp+minor[2]*ytmp+normal[2]*ztmp; |
438 |
|
439 |
param.ajouter(xyz[0]); |
440 |
param.ajouter(xyz[1]); |
441 |
param.ajouter(xyz[2]); |
442 |
|
443 |
param.ajouter(0.5); |
444 |
param.ajouter(x_som); |
445 |
param.ajouter(y_som); |
446 |
param.ajouter(z_som); |
447 |
param.ajouter(0.5); |
448 |
|
449 |
ytmp=0; |
450 |
|
451 |
xyz[0]=center[0]+major[0]*xtmp+minor[0]*ytmp+normal[0]*ztmp; |
452 |
xyz[1]=center[1]+major[1]*xtmp+minor[1]*ytmp+normal[1]*ztmp; |
453 |
xyz[2]=center[2]+major[2]*xtmp+minor[2]*ytmp+normal[2]*ztmp; |
454 |
|
455 |
param.ajouter(xyz[0]); |
456 |
param.ajouter(xyz[1]); |
457 |
param.ajouter(xyz[2]); |
458 |
param.ajouter(1); |
459 |
param.ajouter(x_som); |
460 |
param.ajouter(y_som); |
461 |
param.ajouter(z_som); |
462 |
param.ajouter(1); |
463 |
|
464 |
ytmp=-r; |
465 |
|
466 |
xyz[0]=center[0]+major[0]*xtmp+minor[0]*ytmp+normal[0]*ztmp; |
467 |
xyz[1]=center[1]+major[1]*xtmp+minor[1]*ytmp+normal[1]*ztmp; |
468 |
xyz[2]=center[2]+major[2]*xtmp+minor[2]*ytmp+normal[2]*ztmp; |
469 |
|
470 |
param.ajouter(xyz[0]); |
471 |
param.ajouter(xyz[1]); |
472 |
param.ajouter(xyz[2]); |
473 |
param.ajouter(0.5); |
474 |
param.ajouter(x_som); |
475 |
param.ajouter(y_som); |
476 |
param.ajouter(z_som); |
477 |
param.ajouter(1); |
478 |
xtmp=r; |
479 |
|
480 |
xyz[0]=center[0]+major[0]*xtmp+minor[0]*ytmp+normal[0]*ztmp; |
481 |
xyz[1]=center[1]+major[1]*xtmp+minor[1]*ytmp+normal[1]*ztmp; |
482 |
xyz[2]=center[2]+major[2]*xtmp+minor[2]*ytmp+normal[2]*ztmp; |
483 |
|
484 |
param.ajouter(xyz[0]); |
485 |
param.ajouter(xyz[1]); |
486 |
param.ajouter(xyz[2]); |
487 |
param.ajouter(0.5); |
488 |
param.ajouter(x_som); |
489 |
param.ajouter(y_som); |
490 |
param.ajouter(z_som); |
491 |
param.ajouter(0.5); |
492 |
ytmp=0; |
493 |
|
494 |
xyz[0]=center[0]+major[0]*xtmp+minor[0]*ytmp+normal[0]*ztmp; |
495 |
xyz[1]=center[1]+major[1]*xtmp+minor[1]*ytmp+normal[1]*ztmp; |
496 |
xyz[2]=center[2]+major[2]*xtmp+minor[2]*ytmp+normal[2]*ztmp; |
497 |
|
498 |
param.ajouter(xyz[0]); |
499 |
param.ajouter(xyz[1]); |
500 |
param.ajouter(xyz[2]); |
501 |
param.ajouter(1); |
502 |
param.ajouter(x_som); |
503 |
param.ajouter(y_som); |
504 |
param.ajouter(z_som); |
505 |
param.ajouter(1); |
506 |
|
507 |
|
508 |
} |
509 |
|
510 |
|
511 |
indx_premier_ptctr=19; |
512 |
|
513 |
} |
514 |
|
515 |
|