#include <j2k/Fred/3d/transfor.hpp>Go to the source code of this file.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||||||||||||||||
|
Definition at line 380 of file Model.cpp. Referenced by ModeleurRotationZ().
00386 {
00387 char flag1 = EXTR_NONE, /* flag premier sommet sur l'axe.*/
00388 flag2 = EXTR_NONE, /* flag dernier sommet sur l'axe.*/
00389 flag = OFF; /* Il y a t'il un sommet hors axe.*/
00390
00391 UINT i,
00392 r1, r2; /* compteur boucle. */
00393
00394 double t1, t2, /* Parametres de segment. */
00395 temp1, /* Var intermediaires. */
00396 temp2; /* " " " */
00397
00398 /* On verifie la cohérence des données.
00399 // Le profil est il suceptible de generer quelque chose de correct autour
00400 // de l'axe Z ?
00401 // Pour ce faire, il doit :
00402 // - Avoir un nombre de sommet different de zero.
00403 // - Avoir au moins un sommet non confondus avec l'axe.
00404 // - Tous ses sommets doivent se trouver dans le même demis plans
00405 // limité par l'axe Z. Cela se resume par le fait qu'aucun
00406 // segment ne doit couper directement l'axe zz'. Soit le segment
00407 // projeté sur le plans xy ne doit pas renfermer le point m(0,0).
00408 // On rappelle la définition paramétrique d'un segment :
00409 // P(t) = P1 + (P2-P1)t;
00410 // d'ou avec l'axe corespondant on as : t = -P1 / (P2-P1);
00411 // Si t appartient à [0,1], alors il y a intersection.
00412 // Dans le cas qui nous interesse, appartenance du point m(0,0)
00413 // a un segment ab, on obtient le système suivant:
00414 // 0 = Xa + ( Xb - Xa )* T1
00415 // 0 = Ya + ( Yb - Ya )* T2
00416 // m appartient à ab si T1 = T2 et T1 appartient à [0,1].
00417 // nb : reste les cas particulier ou Xb-Xa = 0 ou Yb-Ya = 0.
00418 */
00419
00420 *flagExtr = EXTR_NONE;
00421
00422 if ( !NbSommet ) return MOD_ROT_ERROR_BAD_DATA_CARDINAL;
00423
00424 /* On regarde si le profil est fermé sur l'axe. */
00425 /* nb - IsOnAxe(...) est une fonction definie plus bas. */
00426 /* on verifi qu'il y a au moins un sommet hors axe. */
00427 /* ---------------------------------------------------- */
00428
00429 /* Le point initial.*/
00430 if ( IsOnAxe( profil[0].x, profil[0].y ) ) {
00431 flag1 = EXTR_SUP;
00432
00433 } else {
00434 flag = ON;
00435 }
00436
00437 /* les point intermediaires.*/
00438 for( i = 1; i < NbSommet-1; i ++ )
00439 if ( !IsOnAxe( profil[i].x, profil[i].y ) ) {
00440 flag = ON;
00441 break;
00442 }
00443
00444 /* Le point final.*/
00445 if ( IsOnAxe( profil[NbSommet-1].x, profil[NbSommet-1].y) ) {
00446 flag2 = EXTR_INF;
00447 } else {
00448 flag = ON;
00449 }
00450
00451 if ( flag == OFF ) return MOD_ROT_ERROR_BAD_DATA_OUT_AXIS;
00452
00453 /* Verification de tous les arcs */
00454 /* ----------------------------- */
00455 for( i = 0; i < NbSommet-1; i++ ) {
00456 temp1 = profil[i+1].x - profil[i].x;
00457 temp2 = profil[i+1].y - profil[i].y;
00458 t1 = -profil[i].x;
00459 t2 = -profil[i].y;
00460
00461 /* On elimine le cas trivial de segment confondu avec l'axe de rotation*/
00462 /* et du même coup, celui des segments parallele à l'axe. */
00463 /* --------------------------------------------------------------------*/
00464 if ( ! temp1&& ! temp2 )
00465 if ( !t1&& !t2 ) return MOD_ROT_ERROR_BAD_DATA_ON_AXIS;
00466 else continue;
00467
00468 /* Nb- __Test_0 et __Test_1 sont des macro declarées plus haut qui
00469 * eliminent les cas où l'intersection des premier et dernier segment
00470 * provient de la fermeture du profil sur l'axe. */
00471 /* On elimine le cas trivial de segment parallele avec l'axe yy'*/
00472 /* -------------------------------------------------------------*/
00473 if ( ! temp1 )
00474 if ( !t1 ) {
00475 t2 /= temp2;
00476 r1 = __Test_0(t2);
00477 r2 = __Test_1(t2);
00478 if ( r1&& r2 ) return MOD_ROT_ERROR_BAD_DATA_INTER;
00479 continue;
00480 }
00481 else continue;
00482
00483 /* On elimine le cas trivial des segments paralleles avec l'axe xx'*/
00484 /* ----------------------------------------------------------------*/
00485 if ( ! temp2 )
00486 if ( !t2 )
00487 {
00488 t1 /= temp1;
00489 r1 = __Test_0(t1);
00490 r2 = __Test_1(t1);
00491 if ( r1&& r2 ) return MOD_ROT_ERROR_BAD_DATA_INTER;
00492 continue;
00493 }
00494 else continue;
00495
00496 /* On cherche l'intersection.*/
00497 /* ---------------------------*/
00498 t1 /= temp1;
00499 t2 /= temp2;
00500
00501 r1 = __Test_0(t1);
00502 r2 = __Test_1(t1);
00503 if ( ( t1 == t2 ) && r1&& r2 )
00504 return MOD_ROT_ERROR_BAD_DATA_INTER;
00505 }
00506
00507 /* A ce niveau tout est OK. On peut generer les sommets.*/
00508 /* -----------------------------------------------------*/
00509
00510 *flagExtr = flag1+flag2;
00511
00512 return SUCCESS;
00513 }
|
|
|
Definition at line 144 of file Model.cpp. Referenced by ProfToProfAxisCAO::GetErrorMsg().
00144 {
00145
00146 if ( num >= _cardinamod_prof_to_prof_mess || num < 0 ) {
00147 return G_Error_Mod_Prof_Mess [MOD_PROF_TO_PROF_ERROR_MSG]
00148
00149 } else {
00150 return G_Error_Mod_Prof_Mess [ num ];
00151 }
00152
00153 }
|
|
|
Definition at line 518 of file Model.cpp. Referenced by RotProfToProfAxisCAO::GetErrorMsg().
00518 {
00519 return ( num >= _cardinamod_rot_mess || num < 0 ) ?
00520 G_Error_Mod_Rot_Mess [MOD_ROT_ERROR_MSG] :
00521 G_Error_Mod_Rot_Mess [ num ]; }
|
|
|
Definition at line 651 of file Model.cpp. 00651 {
00652 if ( num >= _cardinamod_trans_mess || num < 0 ) {
00653 return G_Error_Mod_Trans_Mess [MOD_TRAN_ERROR_MSG];
00654
00655 } else {
00656 return G_Error_Mod_Trans_Mess [ num ];
00657 }
00658
00659 }
|
|
|
Definition at line 845 of file Model.cpp. Referenced by VecAxisCAO::GetErrorMsg().
00845 {
00846
00847 if ( num >= _cardinamod_vec_mess || num < 0 ) {
00848 return G_Error_Mod_Vector_Mess [MOD_VEC_ERROR_MSG];
00849
00850 } else {
00851 return G_Error_Mod_Vector_Mess [ num ];
00852 }
00853
00854 }
|
|
||||||||||||
|
Definition at line 523 of file Model.cpp. Referenced by CheckingProfilRotationZ().
00523 {
00524 return ( fabs(a) <= G_mod_rot_double_precision &&
00525 fabs(b) <= G_mod_rot_double_precision );
00526 }
|
|
||||||||||||||||||||
|
Definition at line 187 of file Model.cpp. Referenced by ModeleurRotationZ().
00188 {
00189
00190 UINT nb;
00191
00192 if ( !nbp || pas <= 1 ) return 0;
00193
00194 /* on recale les angles sur 0-360° */
00195 while ( *angle > 360 ) angle -= 360;
00196 while ( *angle < -360 ) angle += 360;
00197
00198 nb = pas * nbp;
00199
00200 /* les deux extremités sont sur l'axe */
00201 if ( extr == EXTR_BOTH ) nb -= ( 2 * (pas-1) );
00202
00203 /* une seule éxtremité sur l'axe */
00204 if ( extr == EXTR_SUP || extr == EXTR_INF ) nb -= (pas-1);
00205
00206 return nb;
00207 }
|
|
||||||||||||||||||||||||||||||||||||
|
Definition at line 40 of file Model.cpp. Referenced by ProfToProfAxisCAO::GenerateVertex().
00051 {
00052 UINT nbnewsommet,
00053 borneprofilhaut = 0,
00054 borneprofilbas = NbSommet-1,
00055 i, j,
00056 compt = 0;
00057
00058 realtype tx = trans.b.x - trans.a.x,
00059 ty = trans.b.y - trans.a.y,
00060 tz = trans.b.z - trans.a.z,
00061 atx,
00062 aty,
00063 atz,
00064 hom,
00065 t = 0;
00066
00067 /* Verification des données */
00068 /* ------------------------ */
00069 if ( !NbSommet ) return MOD_PROF_TO_PROF_ERROR_BAD_DATA_CARDINAL;
00070
00071 if ( !pas || pas == 1 || ( !tx && !ty && !tz ) ) {
00072 return MOD_PROF_TO_PROF_ERROR_BAD_TRANS_PAR;
00073 }
00074
00075
00076 /* On calcul le nombre de nouveaux sommets */
00077 /* --------------------------------------- */
00078
00079 /* le profil est il un domaine?.*/
00080 if ( profil[0].x == profil[ NbSommet -1 ].x &&
00081 profil[0].y == profil[ NbSommet -1 ].y &&
00082 profil[0].z == profil[ NbSommet -1 ].z )
00083 {
00084 type->pvert = VERT_CLOSE;
00085 borneprofilbas --;
00086
00087 } else {
00088 type->pvert = VERT_OPEN;
00089 }
00090
00091
00092 /* On alloue la table des sommets */
00093 /* ------------------------------ */
00094 nbnewsommet = ((type->pvert == VERT_OPEN) ? NbSommet: NbSommet-1) * pas;
00095
00096 *nbnew = nbnewsommet;
00097 *sommet = (Sommet3D*) calloc( nbnewsommet, sizeof(Sommet3D) );
00098
00099 if ( !(*sommet) ) return MOD_PROF_TO_PROF_ERROR_MEMORY;
00100
00101 /* On commence par copier le profil initial.*/
00102 /* compt est initialisé à 0.*/
00103
00104 for( j = borneprofilhaut; j <= borneprofilbas; j++ ) {
00105 (*sommet)[compt].x = profil[j].x;
00106 (*sommet)[compt].y = profil[j].y;
00107 (*sommet)[compt].z = profil[j].z;
00108 compt++;
00109 }
00110
00111 /* On fait une boucle sur les profils restant.*/
00112 /* t est initialisé à 0.*/
00113
00114 hom = 1.0/(pas-1);
00115
00116 for( i = 1; i < pas; i++ ) {
00117 atx = tx * i;
00118 aty = ty * i;
00119 atz = tz * i;
00120 t += hom;
00121
00122 for ( j = borneprofilhaut; j <= borneprofilbas; j++ ) {
00123 (*sommet)[compt].x = profil[j].x + (profil1[j].x - profil[j].x)* t;
00124 (*sommet)[compt].y = profil[j].y + (profil1[j].y - profil[j].y)* t;
00125 (*sommet)[compt].z = profil[j].z + (profil1[j].z - profil[j].z)* t;
00126
00127 TransVertex( (*sommet)+compt, atx, aty, atz );
00128 compt++;
00129
00130 } // Next j
00131
00132 } // Next i
00133
00134 /* Mise à jour des renseignements sur la forme générée */
00135 /* --------------------------------------------------- */
00136 type->ponaxis = 0;
00137 type->phor = HOR_OPEN;
00138 type->type = SURFACE;
00139
00140 return SUCCESS;
00141
00142 } // ModeleurProfToProf
|
|
||||||||||||||||||||||||||||||||||||
|
Definition at line 209 of file Model.cpp. Referenced by RotProfToProfAxisCAO::GenerateVertex().
00219 {
00220
00221 int error;
00222
00223 char flagExtr,
00224 flagExtr1;
00225
00226 UINT nbnewsommet,
00227 borneprofilhaut,
00228 borneprofilbas,
00229 i, j,
00230 compt = 0,
00231 depart = 0;
00232
00233 double angle_iteration = 0,
00234 angle = angle,
00235 cosangle,
00236 sinangle;
00237
00238 UINT sameprofil = OFF;
00239
00240 realtype t = 0, hom;
00241
00242 /* Verification de la cohérence des données */
00243 /* ---------------------------------------- */
00244 if ( profil == profil1 )
00245 sameprofil = ON;
00246
00247 if ( (error = CheckingProfilRotationZ(
00248 profil, NbSommet, &flagExtr )) != SUCCESS ) return error;
00249
00250 if ( sameprofil == OFF ) {
00251 if ( (error = CheckingProfilRotationZ(
00252 profil1, NbSommet, &flagExtr1 )) != SUCCESS ) return error;
00253
00254 if ( flagExtr != flagExtr1 )
00255 return MOD_ROT_ERROR_BAD_PROFIL_COMBINATION;
00256 }
00257
00258 /* Determine les bornes de traitement pour la generation */
00259
00260 borneprofilhaut = ( flagExtr == EXTR_SUP ||
00261 flagExtr == EXTR_BOTH ) ? (1) : (0);
00262
00263 borneprofilbas = ( flagExtr == EXTR_INF ||
00264 flagExtr == EXTR_BOTH ) ? (NbSommet-2) : (NbSommet-1);
00265
00266 /* les profils sont-ils des domaines ? */
00267 if ( profil[0].x == profil[ NbSommet -1 ].x &&
00268 profil[0].y == profil[ NbSommet -1 ].y &&
00269 profil[0].z == profil[ NbSommet -1 ].z )
00270 {
00271 type->pvert = VERT_CLOSE;
00272 borneprofilbas --;
00273 } else {
00274 type->pvert = VERT_OPEN;
00275 }
00276
00277 if ( profil1[0].x == profil1[ NbSommet -1 ].x &&
00278 profil1[0].y == profil1[ NbSommet -1 ].y &&
00279 profil1[0].z == profil1[ NbSommet -1 ].z )
00280 {
00281 if ( type->pvert != VERT_CLOSE )
00282 return MOD_ROT_ERROR_BAD_PROFIL_COMBINATION;
00283
00284 } else
00285 if ( type->pvert != VERT_OPEN )
00286 return MOD_ROT_ERROR_BAD_PROFIL_COMBINATION;
00287
00288 /* On alloue la table des sommets */
00289 /* ------------------------------- */
00290 nbnewsommet = ModRotGetCardSommet(
00291 ( type->pvert == VERT_OPEN ) ? (NbSommet) : (NbSommet-1),
00292 &angle, pas, flagExtr
00293 );
00294
00295 if ( !nbnewsommet ) return MOD_ROT_ERROR_BAD_ROTATE_PAR;
00296
00297 *nbnew = nbnewsommet;
00298 *sommet = (Sommet3D*) calloc( nbnewsommet, sizeof( Sommet3D ) );
00299
00300 if ( !(*sommet) ) return MOD_ROT_ERROR_MEMORY;
00301
00302 if ( fabs(angle) != COMPLETE_ROTATE&& sameprofil == ON ) {
00303 angle_iteration = DegreeToRad( angle / (pas-1) );
00304
00305 } else {
00306 angle_iteration = DegreeToRad( angle / pas );
00307 }
00308
00309 /* Nb - pas -1 car le profil initial est dejas compris.*/
00310
00311 /* On commence par copier le profil initial.*/
00312 /* compt est initialisé à 0.*/
00313
00314 for( j = borneprofilhaut; j <= borneprofilbas; j++ ) {
00315 (*sommet)[compt].x = profil[j].x;
00316 (*sommet)[compt].y = profil[j].y;
00317 (*sommet)[compt].z = profil[j].z;
00318 compt++;
00319 }
00320
00321 /* On fait une boucle sur les profils restant */
00322 /* depart est initialisé a 0 */
00323
00324 hom = 1.0/(pas-1);
00325
00326 for( i = 1; i < pas; i++ ) {
00327 t += hom;
00328 cosangle = cos(angle_iteration*i);
00329 sinangle = sin(angle_iteration*i);
00330
00331 for( j = borneprofilhaut; j <= borneprofilbas; j++ ) {
00332
00333 (*sommet)[compt].x = profil[j].x + (profil1[j].x - profil[j].x)* t;
00334 (*sommet)[compt].y = profil[j].y + (profil1[j].y - profil[j].y)* t;
00335 (*sommet)[compt].z = profil[j].z + (profil1[j].z - profil[j].z)* t;
00336
00337 RotateVertex( (*sommet)+compt, cosangle, sinangle, Z_AXIS );
00338 compt++;
00339 depart++;
00340
00341 } // Next j
00342
00343 depart = 0;
00344
00345 } // Next i
00346
00347 /* on rajoute si necessaire, les points sur l'axe.*/
00348 if ( flagExtr == EXTR_SUP || flagExtr == EXTR_BOTH ) {
00349 (*sommet)[compt].x = profil[0].x;
00350 (*sommet)[compt].y = profil[0].y;
00351 (*sommet)[compt].z = profil[0].z;
00352 compt++;
00353 }
00354
00355 if ( flagExtr == EXTR_INF || flagExtr == EXTR_BOTH ) {
00356 (*sommet)[compt].x = profil[NbSommet-1].x;
00357 (*sommet)[compt].y = profil[NbSommet-1].y;
00358 (*sommet)[compt].z = profil[NbSommet-1].z;
00359 }
00360
00361 /* Mise à jour des renseignements sur la forme générée */
00362 /* --------------------------------------------------- */
00363 type->ponaxis = flagExtr;
00364
00365 type->phor = (angle == COMPLETE_ROTATE && sameprofil == ON ) ?
00366 HOR_CLOSE : HOR_OPEN;
00367
00368 type->type = ( type->phor == HOR_CLOSE &&
00369 ( type->ponaxis == EXTR_BOTH ||
00370 type->pvert == VERT_CLOSE )
00371 ) ? VOLUME : SURFACE;
00372
00373 return SUCCESS;
00374 }
|
|
||||||||||||||||||||||||||||||||
|
Definition at line 551 of file Model.cpp. 00559 {
00560
00561 UINT nbnewsommet,
00562 borneprofilhaut = 0,
00563 borneprofilbas = NbSommet-1,
00564 i, j,
00565 compt = 0,
00566 depart = 0;
00567
00568 realtype tx = trans.b.x - trans.a.x,
00569 ty = trans.b.y - trans.a.y,
00570 tz = trans.b.z - trans.a.z,
00571 atx,
00572 aty,
00573 atz;
00574
00575 /* Verification des données */
00576 /* ------------------------ */
00577 if ( !NbSommet ) return MOD_TRAN_ERROR_BAD_DATA_CARDINAL;
00578
00579
00580 if ( !pas || ( !tx && !ty && !tz ) )
00581 return MOD_TRAN_ERROR_BAD_TRANS_PAR;
00582
00583 /* On calcul le nombre de nouveaux sommets */
00584 /* --------------------------------------- */
00585
00586 /* Le profil est-il un domaine ? */
00587 if ( profil[0].x == profil[ NbSommet -1 ].x &&
00588 profil[0].y == profil[ NbSommet -1 ].y &&
00589 profil[0].z == profil[ NbSommet -1 ].z )
00590 {
00591 type->pvert = VERT_CLOSE;
00592 borneprofilbas --;
00593
00594 } else {
00595 type->pvert = VERT_OPEN;
00596 }
00597
00598
00599 /* On alloue la table des sommets */
00600 /* ------------------------------- */
00601 nbnewsommet = ( (type->pvert == VERT_OPEN) ?
00602 (NbSommet): (NbSommet-1) ) * pas;
00603
00604 *nbnew = nbnewsommet;
00605 *sommet = (Sommet3D*) calloc( nbnewsommet, sizeof(Sommet3D) );
00606 if ( !(*sommet) ) return MOD_TRAN_ERROR_MEMORY;
00607
00608 /* On commence par copier le profil initial.*/
00609 /* compt est initialisé à 0.*/
00610
00611 for ( j = borneprofilhaut; j <= borneprofilbas; j++ ) {
00612 (*sommet)[compt].x = profil[j].x;
00613 (*sommet)[compt].y = profil[j].y;
00614 (*sommet)[compt].z = profil[j].z;
00615 compt++;
00616 }
00617
00618 /* On fait une boucle sur les profils restant.*/
00619 /* depart est initialisé a 0.*/
00620
00621 for( i = 1; i < pas; i++ ) {
00622 atx = tx * i;
00623 aty = ty * i;
00624 atz = tz * i;
00625
00626 for( j = borneprofilhaut; j <= borneprofilbas; j++ ) {
00627 (*sommet)[compt].x = (*sommet)[depart].x;
00628 (*sommet)[compt].y = (*sommet)[depart].y;
00629 (*sommet)[compt].z = (*sommet)[depart].z;
00630
00631 TransVertex( (*sommet)+compt, atx, aty, atz );
00632
00633 compt++;
00634 depart++;
00635
00636 } // Next j
00637
00638 depart = 0;
00639
00640 } // Next i
00641
00642 /* Mise à jour des renseignements sur la forme générée */
00643 /* --------------------------------------------------- */
00644 type->ponaxis = 0;
00645 type->phor = HOR_OPEN;
00646 type->type = SURFACE;
00647
00648 return SUCCESS;
00649 }
|
|
||||||||||||||||||||||||||||||||
|
Definition at line 684 of file Model.cpp. Referenced by VecAxisCAO::GenerateVertex().
00692 {
00693
00694 UINT nbnewsommet,
00695 borneprofilhaut = 0,
00696 borneprofilbas = NbSommet-1,
00697 i, j,
00698 compt = 0,
00699 depart = 0;
00700
00701 /* Verification des données */
00702 /* ------------------------ */
00703 if ( !NbSommet ) return MOD_VEC_ERROR_BAD_DATA_CARDINAL;
00704 if ( !nbvec ) return MOD_VEC_ERROR_BAD_TRANS_PAR;
00705
00706 realtype tx, ty, tz;
00707
00708 for( i = 0; i != nbvec; i++ ) {
00709
00710 tx = trans[i].b.x - trans[i].a.x;
00711 ty = trans[i].b.y - trans[i].a.y;
00712 tz = trans[i].b.z - trans[i].a.z;
00713 if ( !tx && !ty && !tz )
00714 return MOD_VEC_ERROR_BAD_TRANS_PAR;
00715 }
00716
00717 /* On calcul le nombre de nouveaux sommets */
00718 /* --------------------------------------- */
00719
00720 /* Le profil est-il un domaine ? */
00721 if ( profil[0].x == profil[ NbSommet -1 ].x&&
00722 profil[0].y == profil[ NbSommet -1 ].y&&
00723 profil[0].z == profil[ NbSommet -1 ].z )
00724 {
00725 type->pvert = VERT_CLOSE;
00726 borneprofilbas --;
00727
00728 } else {
00729 type->pvert = VERT_OPEN;
00730 }
00731
00732 nbnewsommet = ( (type->pvert == VERT_OPEN) ? (NbSommet): (NbSommet-1)
00733 ) * nbvec;
00734
00735 /* On alloue la table des sommets */
00736 /* ------------------------------ */
00737
00738 *nbnew = nbnewsommet;
00739 *sommet = (Sommet3D*) calloc ( nbnewsommet, sizeof(Sommet3D) );
00740
00741 if ( !(*sommet) ) return MOD_VEC_ERROR_MEMORY;
00742
00743 /* On commence par copier le profil initial.*/
00744 /* compt est initialisé à 0.*/
00745
00746 for ( j = borneprofilhaut; j <= borneprofilbas; j++ ) {
00747 (*sommet)[compt].x = profil[j].x;
00748 (*sommet)[compt].y = profil[j].y;
00749 (*sommet)[compt].z = profil[j].z;
00750 compt++;
00751 }
00752
00753 /* pour recuperer les sin et cos des angles entre les vecteurs successif
00754 ( le vecteur [0] est le vecteur initial de base ), on recupere les sin
00755 et cos directeur des 2 vecteurs et l'on en determine la difference par
00756 sin(a-b) = sin(a)cos(b)-cos(a)sin(b).
00757 cos(a-b)*cos(a-b) = 1 - sin(a-b)*sin(a-b).
00758 */
00759
00760 realtype sinalpha, cosalpha,
00761 sinbeta, cosbeta,
00762 lgr,
00763 x, y, z,
00764 xt, yt, zt,
00765 sinalpha1, cosalpha1,
00766 sinbeta1, cosbeta1,
00767 sinalpha2, cosalpha2,
00768 sinbeta2, cosbeta2,
00769 lgr1,
00770 x1, y1, z1;
00771
00772 xt = trans[0].a.x;
00773 yt = trans[0].a.y;
00774 zt = trans[0].a.z;
00775
00776 x = trans[0].b.x - trans[0].b.x;
00777 y = trans[0].b.y - trans[0].b.y;
00778 z = trans[0].b.z - trans[0].b.z;
00779
00780 lgr = sqrt( x*x + y*y + z*z );
00781
00782 sinalpha = (z == 0) ? (0) : (lgr/z);
00783 cosalpha = sqrt( 1 - sinalpha * sinalpha );
00784
00785 sinbeta = (x == 0) ? (0) : (lgr/x);
00786 cosbeta = sqrt( 1 - sinbeta * sinbeta );
00787
00788 /* On fait une boucle sur les profils restants. */
00789 /* départ est initialisé a 0. */
00790
00791 for( i = 1; i < nbvec; i++ ) {
00792 x1 = trans[i].b.x - trans[i].b.x;
00793 y1 = trans[i].b.y - trans[i].b.y;
00794 z1 = trans[i].b.z - trans[i].b.z;
00795
00796 lgr1 = sqrt( x1*x1 + y1*y1 + z1*z1 );
00797
00798 sinalpha1 = (z1 == 0)?(0):(lgr1/z1);
00799 cosalpha1 = sqrt(1-sinalpha1*sinalpha1);
00800 sinbeta1 = (x1 == 0)?(0):(lgr1/x1);
00801 cosbeta1 = sqrt(1-sinbeta1*sinbeta1);
00802
00803 sinalpha2 = sinalpha*cosalpha1 - sinalpha1*cosalpha;
00804 cosalpha2 = sqrt(1 - sinalpha2*sinalpha2);
00805 sinbeta2 = sinbeta*cosbeta1 - sinbeta1*cosbeta;
00806 cosbeta2 = sqrt(1 - sinbeta2*sinbeta2);
00807
00808 for( j = borneprofilhaut; j <= borneprofilbas; j++ ) {
00809 (*sommet)[compt].x = (*sommet)[depart].x;
00810 (*sommet)[compt].y = (*sommet)[depart].y;
00811 (*sommet)[compt].z = (*sommet)[depart].z;
00812
00813 /* on ramène le vecteur initial en O.*/
00814 TransVertex( (*sommet)+compt, -xt, -yt, -zt );
00815
00816 /* les rotations.*/
00817 RotateVertex( (*sommet)+compt, cosalpha2, sinalpha2, Z_AXIS);
00818 RotateVertex( (*sommet)+compt, cosbeta2, sinbeta2, X_AXIS);
00819
00820 /* on translate sur le vecteur desiré.*/
00821 TransVertex( (*sommet)+compt,
00822 trans[i].a.x,
00823 trans[i].a.y,
00824 trans[i].a.z );
00825
00826 compt++;
00827 depart++;
00828
00829 } // Next j
00830
00831 depart = 0;
00832
00833 } // Next i
00834
00835 /* Mise à jour des renseignements sur la forme générée.*/
00836 /* ----------------------------------------------------*/
00837 type->ponaxis = 0;
00838 type->phor = HOR_OPEN;
00839 type->type = SURFACE;
00840
00841 return SUCCESS;
00842 }
|
|
||||||||||||
|
Definition at line 11 of file Model.cpp. 00011 {
00012 double vx = v[_X_] * v[_X_];
00013 double vy = v[_Y_] * v[_Y_];
00014 double vz = ( mode == __3D ) ? v[_Z_]*v[_Z_] : 0;
00015
00016 return sqrt( vx + vy + vz );
00017 }
|
1.2.11.1 written by Dimitri van Heesch,
© 1997-2001