/* Mathematiques de l'informatique graphique */ /* Transformation geometrique 3D */ /* en coordonnees homogenes */ /* */ /* Auteur: Nicolas JANEY */ /* nicolas.janey@univ-fcomte.fr */ /* Mars 2020 */ #include #include #include #include "TG3D.h" #include "CH3D.h" #include "Pos3D.h" #include "Dir3D.h" /* Construit la TG3D identite */ TG3D::TG3D(void) { for ( int l = 0 ; l < 4 ; ++l ) { for ( int c = 0 ; c < 4 ; ++c ) { mat[l][c] = (l == c) ? 1.0F : 0.0F; } } } /* Construit la TG3D clone de tg */ TG3D::TG3D(TG3D *tg) { for ( int l = 0 ; l < 4 ; ++l ) { for ( int c = 0 ; c < 4 ; ++c ) { mat[l][c] = tg->mat[l][c]; } } } /* Destructeur */ TG3D::~TG3D(void) { } /* Calcul de la composition */ /* de la transformation geometrique this */ /* par la transformation geometrique rhs */ TG3D TG3D::mult(const TG3D& rhs) { TG3D res; for ( int l = 0 ; l < 4 ; ++l ) { for ( int c = 0 ; c < 4 ; ++c ) { res.mat[l][c] = 0.0F; for ( int k = 0 ; k < 4 ; ++k ) { // [l][k] *[k][c] res.mat[l][c] += this->mat[l][k] * rhs.mat[k][c]; } } } return res; } /* Calcul de la transformation */ /* de la Pos3D p */ /* par la transformation geometrique this */ Pos3D TG3D::mult(Pos3D& p) { return p.mult(this); } /* Calcul de la transformation */ /* de la Dir3D d */ /* par la transformation geometrique this */ Dir3D TG3D::mult(Dir3D& d) { return d.mult(this); } /* Methode d'affichage texte */ void TG3D::print(void) { for ( int l = 0 ; l < 4 ; l++ ) printf("%10.4f %10.4f %10.4f %10.4f\n",mat[l][0],mat[l][1],mat[l][2],mat[l][3]); }