/* Mathematiques de l'Infographie */ /* Test des classes TG3D, Tr3D, Rt3D et Sc3D */ /* */ /* 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" #include "Tr3D.h" #include "Rt3D.h" #include "Sc3D.h" static void afficher(char *message,CH3D *ch) { printf("%s",message); ch->print(); printf("\n"); } void main(void) { #if defined(WIN32) || defined(WIN64) #if defined(_DEBUG) _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); //_crtBreakAlloc = 120; #endif #endif Tr3D tr1(1.8,-3.4,6.7); Tr3D *tr2 = new Tr3D(-4.5,0.1,3.2); Tr3D tr3; Tr3D tr4(tr2); printf("Translations\n"); tr1.print(); printf("\n"); tr2->print(); printf("\n"); tr3.print(); printf("\n"); tr4.print(); printf("\n"); Rt3D rt1(45.0,-1.3,2.3,3.7); Rt3D *rt2 = new Rt3D(30.0,&Dir3D(2.1,-0.7,1.8)); Rt3D rt3; Rt3D rt4(rt2); Rt3D *rt5 = new Rt3D(30.0,&Dir3D(1.0,0.0,0.0)); printf("Rotations\n"); rt1.print(); printf("\n"); rt2->print(); printf("\n"); rt3.print(); printf("\n"); rt4.print(); printf("\n"); rt5->print(); printf("\n"); Sc3D sc1(0.3,1.3,0.7); Sc3D *sc2 = new Sc3D(0.2,0.9,1.7); Sc3D sc3; Sc3D sc4(sc2); printf("Zooms\n"); sc1.print(); printf("\n"); sc2->print(); printf("\n"); sc3.print(); printf("\n"); sc4.print(); printf("\n"); Pos3D p1(2.0,3.0,4.0); Pos3D *p2 = new Pos3D(-1.1,-0.2,-2.3); Dir3D d1(2.0,3.0,4.0); Dir3D *d2 = new Dir3D(-1.1,-0.2,-2.3); printf("Transformations de positions 3D\n"); afficher("p1 : ",&p1); tr1.transformation(&p1); afficher("p1 : ",&p1); printf("\n"); afficher("p2 : ",p2); tr2->transformation(p2); afficher("p2 : ",p2); printf("\n"); printf("Transformations de directions 3D\n"); afficher("d1 : ",&d1); rt1.transformation(&d1); afficher("d1 : ",&d1); printf("\n"); afficher("d2 : ",d2); tr2->transformation(d2); afficher("d2 : ",d2); printf("\n"); printf("Composition de transformations geometriques\n"); TG3D tg1; TG3D tg2; tg1.composition(&tr1,&rt1); tg2.composition(&rt1,&tr1); tg1.print(); printf("\n"); tg2.print(); printf("\n"); delete(sc2); delete(rt5); delete(rt2); delete(tr2); delete(p2); delete(d2); }