/* Mathematiques de l'Infographie */ /* Test des classes CH3D, Pos3D et Dir3D */ /* */ /* Auteur: Nicolas JANEY */ /* nicolas.janey@univ-fcomte.fr */ /* Mars 2019 */ #if defined(WIN32) || defined(WIN64) #define _CRTDBG_MAP_ALLOC #if defined(_DEBUG) #define _AFXDLL #include #endif #endif #include #if defined(WIN32) || defined(WIN64) #include #endif #include #include "Pos3D.h" #include "Dir3D.h" void main(void) { #if defined(WIN32) || defined(WIN64) #if defined(_DEBUG) _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); //_crtBreakAlloc = 120; #endif #endif Pos3D p1(2.0,3.0,4.0); Pos3D *p2 = new Pos3D(-1.1,-0.2,-2.3); p1.print(); printf("\n"); p2->print(); printf("\n"); printf("%lf\n",p1.distance(p2)); printf("%lf\n",p2->distance(&p1)); printf("%lf\n",Pos3D::distance(&p1,p2)); printf("\n"); Dir3D d1(1.1,2.3,-2.1); Dir3D *d2 = new Dir3D(&p1,p2); d1.print(); printf("\n"); d2->print(); printf("\n"); printf("%lf\n",d1.norme()); printf("%lf\n",d2->norme()); d1.normalisation(); d2->normalisation(); d1.print(); printf(" %25.20lf\n",d1.norme()); d2->print(); printf(" %25.20lf\n",d2->norme()); printf("%lf\n",d1.produitScalaire(d2)); printf("%lf\n",d2->produitScalaire(&d1)); printf("%lf\n",Dir3D::produitScalaire(&d1,d2)); Dir3D *d3 = Dir3D::produitVectoriel(&d1,d2); d3->print(); printf("\n"); d1.produitVectoriel(d2); d1.print(); printf("\n"); printf("\n"); d1.produitVectoriel(&d1); d1.print(); printf("\n"); delete(d3); delete(d2); delete(p2); }