1 |
|
5 |
//------------------------------------------------------------
|
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 |
|
|
// sat_ellipse.cpp
|
16 |
|
|
//
|
17 |
|
|
//------------------------------------------------------------
|
18 |
|
|
//------------------------------------------------------------
|
19 |
|
|
// COPYRIGHT 2000
|
20 |
|
|
// Version du 02/03/2006 à 11H24
|
21 |
|
|
//------------------------------------------------------------
|
22 |
|
|
//------------------------------------------------------------
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
#include "gestionversion.h"
|
26 |
|
|
#include "sat_ellipse.h"
|
27 |
|
|
#include "tpl_fonction.h"
|
28 |
|
|
#include "ot_mathematique.h"
|
29 |
|
|
#include "constantegeo.h"
|
30 |
|
|
|
31 |
|
|
#include <math.h>
|
32 |
|
|
|
33 |
|
|
SAT_ELLIPSE::SAT_ELLIPSE(unsigned long num):SAT_COURBE(num)
|
34 |
|
|
{
|
35 |
|
|
}
|
36 |
|
|
|
37 |
|
|
SAT_ELLIPSE::SAT_ELLIPSE():SAT_COURBE()
|
38 |
|
|
{
|
39 |
|
|
}
|
40 |
|
|
|
41 |
|
|
SAT_ELLIPSE::~SAT_ELLIPSE()
|
42 |
|
|
{
|
43 |
|
|
}
|
44 |
|
|
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
void SAT_ELLIPSE::evaluer(double t,double *xyz)
|
48 |
|
|
{
|
49 |
|
|
xyz[0]=center[0]+major[0]*a*cos(t)+minor[0]*a*ratio*sin(t);
|
50 |
|
|
xyz[1]=center[1]+major[1]*a*cos(t)+minor[1]*a*ratio*sin(t);
|
51 |
|
|
xyz[2]=center[2]+major[2]*a*cos(t)+minor[2]*a*ratio*sin(t);
|
52 |
|
|
}
|
53 |
|
|
|
54 |
|
|
void SAT_ELLIPSE::deriver(double t,double *xyz)
|
55 |
|
|
{
|
56 |
|
|
xyz[0]= -major[0]*a*sin(t)+minor[0]*a*ratio*cos(t);
|
57 |
|
|
xyz[1]= -major[1]*a*sin(t)+minor[1]*a*ratio*cos(t);
|
58 |
|
|
xyz[2]= -major[2]*a*sin(t)+minor[2]*a*ratio*cos(t);
|
59 |
|
|
|
60 |
|
|
}
|
61 |
|
|
|
62 |
|
|
void SAT_ELLIPSE::deriver_seconde(double t,double *ddxyz,double* dxyz ,double* xyz )
|
63 |
|
|
{
|
64 |
|
|
ddxyz[0]= -major[0]*a*cos(t)-minor[0]*a*ratio*sin(t);
|
65 |
|
|
ddxyz[1]= -major[1]*a*cos(t)-minor[1]*a*ratio*sin(t);
|
66 |
|
|
ddxyz[2]= -major[2]*a*cos(t)-minor[2]*a*ratio*sin(t);
|
67 |
|
|
if (dxyz!=NULL) deriver(t,dxyz);
|
68 |
|
|
if (xyz!=NULL) evaluer(t,xyz);
|
69 |
|
|
}
|
70 |
|
|
|
71 |
|
|
void SAT_ELLIPSE::inverser(double& t,double *xyz,double precision)
|
72 |
|
|
{
|
73 |
|
|
double vecsol[3],veccoef1[3],veccoef2[3];
|
74 |
|
|
vecsol[0]=xyz[0]-center[0];
|
75 |
|
|
vecsol[1]=xyz[1]-center[1];
|
76 |
|
|
vecsol[2]=xyz[2]-center[2];
|
77 |
|
|
veccoef1[0]=major[0]*a;
|
78 |
|
|
veccoef1[1]=major[1]*a;
|
79 |
|
|
veccoef1[2]=major[2]*a;
|
80 |
|
|
veccoef2[0]=minor[0]*a*ratio;
|
81 |
|
|
veccoef2[1]=minor[1]*a*ratio;
|
82 |
|
|
veccoef2[2]=minor[2]*a*ratio;
|
83 |
|
|
|
84 |
|
|
int num1,num2;
|
85 |
|
|
double det= veccoef1[0]*veccoef2[1]-veccoef1[1]*veccoef2[0];
|
86 |
|
|
if (OPERATEUR::egal(det,0.0,0.0001))
|
87 |
|
|
{
|
88 |
|
|
det= veccoef1[0]*veccoef2[2]-veccoef1[2]*veccoef2[0];
|
89 |
|
|
if (OPERATEUR::egal(det,0.0,0.0001))
|
90 |
|
|
{
|
91 |
|
|
det= veccoef1[1]*veccoef2[2]-veccoef1[2]*veccoef2[1];
|
92 |
|
|
num1=1;num2=2;
|
93 |
|
|
}
|
94 |
|
|
else
|
95 |
|
|
{
|
96 |
|
|
num1=0;num2=2;
|
97 |
|
|
}
|
98 |
|
|
}
|
99 |
|
|
else
|
100 |
|
|
{
|
101 |
|
|
num1=0;num2=1;
|
102 |
|
|
}
|
103 |
|
|
double co= (vecsol[num1]*veccoef2[num2]-vecsol[num2]*veccoef2[num1])/det;
|
104 |
|
|
double si= (vecsol[num2]*veccoef1[num1]-vecsol[num1]*veccoef1[num2])/det;
|
105 |
|
|
if (co>1.) co=1.;
|
106 |
|
|
if (co<(-1.)) co=(-1.);
|
107 |
|
|
t=acos(co);
|
108 |
|
|
if (si<-0.0001) t= -t;
|
109 |
|
|
if (t<-0.0001) t=t+2*M_PI;
|
110 |
|
|
|
111 |
|
|
|
112 |
|
|
|
113 |
|
|
}
|
114 |
|
|
|
115 |
|
|
double SAT_ELLIPSE::get_tmin()
|
116 |
|
|
{
|
117 |
|
|
return 0.;
|
118 |
|
|
}
|
119 |
|
|
|
120 |
|
|
double SAT_ELLIPSE::get_tmax()
|
121 |
|
|
{
|
122 |
|
|
return 2.*M_PI;
|
123 |
|
|
}
|
124 |
|
|
|
125 |
|
|
int SAT_ELLIPSE::est_periodique(void)
|
126 |
|
|
{
|
127 |
|
|
return 1;
|
128 |
|
|
}
|
129 |
|
|
|
130 |
|
|
double SAT_ELLIPSE::get_periode(void)
|
131 |
|
|
{
|
132 |
|
|
return 2.*M_PI;
|
133 |
|
|
}
|
134 |
|
|
|
135 |
|
|
|
136 |
|
|
void SAT_ELLIPSE::calcul_parametre(void)
|
137 |
|
|
{
|
138 |
|
|
a=sqrt(major[0]*major[0]+major[1]*major[1]+major[2]*major[2]);
|
139 |
|
|
OT_VECTEUR_3D u(major);
|
140 |
|
|
OT_VECTEUR_3D w(normal);
|
141 |
|
|
OT_VECTEUR_3D v=w&u;
|
142 |
|
|
u.norme();
|
143 |
|
|
w.norme();
|
144 |
|
|
v.norme();
|
145 |
|
|
major[0]=u.get_x();
|
146 |
|
|
major[1]=u.get_y();
|
147 |
|
|
major[2]=u.get_z();
|
148 |
|
|
minor[0]=v.get_x();
|
149 |
|
|
minor[1]=v.get_y();
|
150 |
|
|
minor[2]=v.get_z();
|
151 |
|
|
normal[0]=w.get_x();
|
152 |
|
|
normal[1]=w.get_y();
|
153 |
|
|
normal[2]=w.get_z();
|
154 |
|
|
}
|
155 |
|
|
|
156 |
|
|
|
157 |
|
|
|
158 |
|
|
|
159 |
|
|
|
160 |
|
|
|
161 |
|
|
|
162 |
|
|
|
163 |
|
|
|
164 |
|
|
|
165 |
|
|
|
166 |
|
|
|
167 |
|
|
|
168 |
|
|
double equation_longueur(SAT_ELLIPSE& ellipse,double t)
|
169 |
|
|
{
|
170 |
|
|
return sqrt(ellipse.a*ellipse.a*sin(t)*sin(t)+ellipse.a*ellipse.a*ellipse.ratio*ellipse.ratio*cos(t)*cos(t));
|
171 |
|
|
}
|
172 |
|
|
|
173 |
|
|
|
174 |
|
|
|
175 |
|
|
|
176 |
|
|
double SAT_ELLIPSE::get_longueur(double t1,double t2,double precis)
|
177 |
|
|
{
|
178 |
|
|
if (ratio!=1.)
|
179 |
|
|
{
|
180 |
|
|
TPL_FONCTION1<double,SAT_ELLIPSE,double> longueur_ellipse(*this,equation_longueur);
|
181 |
|
|
return longueur_ellipse.integrer_gauss_2(t1,t2);
|
182 |
|
|
}
|
183 |
|
|
else
|
184 |
|
|
{
|
185 |
|
|
return a*(t2-t1);
|
186 |
|
|
}
|
187 |
|
|
|
188 |
|
|
|
189 |
|
|
}
|
190 |
|
|
|
191 |
|
|
|
192 |
|
|
int SAT_ELLIPSE::get_type_geometrique(TPL_LISTE_ENTITE<double> ¶m)
|
193 |
|
|
{
|
194 |
|
|
param.ajouter(center[0]);
|
195 |
|
|
param.ajouter(center[1]);
|
196 |
|
|
param.ajouter(center[2]);
|
197 |
|
|
param.ajouter(major[0]);
|
198 |
|
|
param.ajouter(major[1]);
|
199 |
|
|
param.ajouter(major[2]);
|
200 |
|
|
param.ajouter(normal[0]);
|
201 |
|
|
param.ajouter(normal[1]);
|
202 |
|
|
param.ajouter(normal[2]);
|
203 |
|
|
param.ajouter(a);
|
204 |
|
|
param.ajouter(a*ratio);
|
205 |
|
|
return MGCo_ELLIPSE;
|
206 |
|
|
}
|
207 |
|
|
|
208 |
|
|
|
209 |
|
|
|
210 |
|
|
|
211 |
francois |
19 |
void SAT_ELLIPSE::get_param_NURBS(int& indx_premier_ptctr,TPL_LISTE_ENTITE<double> ¶m)
|
212 |
|
5 |
{
|
213 |
|
|
double xyz[3];
|
214 |
|
|
|
215 |
|
|
// The first parameter indicate the code access
|
216 |
|
|
param.ajouter(1);
|
217 |
|
|
|
218 |
|
|
// The follewing two parameters of the list indicate the orders of the net points
|
219 |
|
|
|
220 |
|
|
param.ajouter(3);
|
221 |
|
|
param.ajouter(0);
|
222 |
|
|
|
223 |
|
|
// The follewing two parameters indicate the number of rows and colons of the control points
|
224 |
|
|
// respectively to the two parameters directions
|
225 |
|
|
|
226 |
|
|
param.ajouter(7);
|
227 |
|
|
param.ajouter(0);
|
228 |
|
|
|
229 |
|
|
// this present the knot vector in the u-direction
|
230 |
|
|
|
231 |
|
|
param.ajouter(0);
|
232 |
|
|
param.ajouter(0);
|
233 |
|
|
param.ajouter(0);
|
234 |
|
|
param.ajouter(0.25);
|
235 |
|
|
param.ajouter(0.5);
|
236 |
|
|
param.ajouter(0.5);
|
237 |
|
|
param.ajouter(0.75);
|
238 |
|
|
param.ajouter(1);
|
239 |
|
|
param.ajouter(1);
|
240 |
|
|
param.ajouter(1);
|
241 |
|
|
|
242 |
|
|
|
243 |
|
|
//the first control point
|
244 |
|
|
|
245 |
|
|
double ax= a;
|
246 |
|
|
double ay= 0;
|
247 |
|
|
|
248 |
|
|
xyz[0]=center[0]+major[0]*ax+minor[0]*ay;
|
249 |
|
|
xyz[1]=center[1]+major[1]*ax+minor[1]*ay;
|
250 |
|
|
xyz[2]=center[2]+major[2]*ax+minor[2]*ay;
|
251 |
|
|
|
252 |
|
|
param.ajouter(xyz[0]);
|
253 |
|
|
param.ajouter(xyz[1]);
|
254 |
|
|
param.ajouter(xyz[2]);
|
255 |
|
|
param.ajouter(1);
|
256 |
|
|
|
257 |
|
|
// the second control point have such local cordinate (rayon,rayon)
|
258 |
|
|
|
259 |
|
|
ay=a*ratio;
|
260 |
|
|
|
261 |
|
|
xyz[0]=center[0]+major[0]*ax+minor[0]*ay;
|
262 |
|
|
xyz[1]=center[1]+major[1]*ax+minor[1]*ay;
|
263 |
|
|
xyz[2]=center[2]+major[2]*ax+minor[2]*ay;
|
264 |
|
|
|
265 |
|
|
|
266 |
|
|
|
267 |
|
|
param.ajouter(xyz[0]);
|
268 |
|
|
param.ajouter(xyz[1]);
|
269 |
|
|
param.ajouter(xyz[2]);
|
270 |
|
|
param.ajouter(0.5);
|
271 |
|
|
|
272 |
|
|
//the third control point have such local cordinate (-rayon,rayon)
|
273 |
|
|
|
274 |
|
|
|
275 |
|
|
ax=-a;
|
276 |
|
|
|
277 |
|
|
xyz[0]=center[0]+major[0]*ax+minor[0]*ay;
|
278 |
|
|
xyz[1]=center[1]+major[1]*ax+minor[1]*ay;
|
279 |
|
|
xyz[2]=center[2]+major[2]*ax+minor[2]*ay;
|
280 |
|
|
|
281 |
|
|
|
282 |
|
|
param.ajouter(xyz[0]);
|
283 |
|
|
param.ajouter(xyz[1]);
|
284 |
|
|
param.ajouter(xyz[2]);
|
285 |
|
|
param.ajouter(0.5);
|
286 |
|
|
|
287 |
|
|
//The forth point have the local cordinate at(-rayon,rayon)
|
288 |
|
|
|
289 |
|
|
ay=0;
|
290 |
|
|
|
291 |
|
|
xyz[0]=center[0]+major[0]*ax+minor[0]*ay;
|
292 |
|
|
xyz[1]=center[1]+major[1]*ax+minor[1]*ay;
|
293 |
|
|
xyz[2]=center[2]+major[2]*ax+minor[2]*ay;
|
294 |
|
|
|
295 |
|
|
|
296 |
|
|
param.ajouter(xyz[0]);
|
297 |
|
|
param.ajouter(xyz[1]);
|
298 |
|
|
param.ajouter(xyz[2]);
|
299 |
|
|
param.ajouter(1);
|
300 |
|
|
|
301 |
|
|
|
302 |
|
|
//the fifth control point have the corfinate in the local cordinate (-rayon,-rayon)
|
303 |
|
|
|
304 |
|
|
ay=-a*ratio;
|
305 |
|
|
|
306 |
|
|
xyz[0]=center[0]+major[0]*ax+minor[0]*ay;
|
307 |
|
|
xyz[1]=center[1]+major[1]*ax+minor[1]*ay;
|
308 |
|
|
xyz[2]=center[2]+major[2]*ax+minor[2]*ay;
|
309 |
|
|
|
310 |
|
|
|
311 |
|
|
|
312 |
|
|
|
313 |
|
|
param.ajouter(xyz[0]);
|
314 |
|
|
param.ajouter(xyz[1]);
|
315 |
|
|
param.ajouter(xyz[2]);
|
316 |
|
|
param.ajouter(0.5);
|
317 |
|
|
|
318 |
|
|
//The sixth control point have the cordiante in the local coordinate (rayon,-rayon)
|
319 |
|
|
|
320 |
|
|
ax=a;
|
321 |
|
|
|
322 |
|
|
xyz[0]=center[0]+major[0]*ax+minor[0]*ay;
|
323 |
|
|
xyz[1]=center[1]+major[1]*ax+minor[1]*ay;
|
324 |
|
|
xyz[2]=center[2]+major[2]*ax+minor[2]*ay;
|
325 |
|
|
|
326 |
|
|
|
327 |
|
|
param.ajouter(xyz[0]);
|
328 |
|
|
param.ajouter(xyz[1]);
|
329 |
|
|
param.ajouter(xyz[2]);
|
330 |
|
|
param.ajouter(0.5);
|
331 |
|
|
|
332 |
|
|
//The last control point have the same local cordinate with rhe first control point (rayon, 0)
|
333 |
|
|
|
334 |
|
|
ay=0;
|
335 |
|
|
|
336 |
|
|
xyz[0]=center[0]+major[0]*ax+minor[0]*ay;
|
337 |
|
|
xyz[1]=center[1]+major[1]*ax+minor[1]*ay;
|
338 |
|
|
xyz[2]=center[2]+major[2]*ax+minor[2]*ay;
|
339 |
|
|
|
340 |
|
|
|
341 |
|
|
param.ajouter(xyz[0]);
|
342 |
|
|
param.ajouter(xyz[1]);
|
343 |
|
|
param.ajouter(xyz[2]);
|
344 |
|
|
param.ajouter(1);
|
345 |
|
|
|
346 |
francois |
19 |
indx_premier_ptctr=15;
|
347 |
|
|
|
348 |
|
5 |
}
|