/* Mathematiques de l'informatique graphique */ /* Coordonnees homogenes en 3D */ /* */ /* Mars 2021 */ #include #include "CH3D.h" #include "Pos3D.h" #include "Dir3D.h" #include "TG3D.h" /* Construit la position origine */ CH3D::CH3D(void) : x(0.0F),y(0.0F),z(0.0F),w(1.0F) { } /* Construit la CH3D (xp,yp,zp,wp) */ CH3D::CH3D(float xp, float yp, float zp, float wp) : x(xp),y(yp),z(zp),w(wp) { } /* Construit un clone de la CH3D ch */ CH3D::CH3D(CH3D *ch) : x(ch->x),y(ch->y),z(ch->z),w(ch->w) { } /* Destructeur */ CH3D::~CH3D(void) { } /* Calcul de la transformation de this */ /* par la transformation geometrique tg */ void CH3D::mult(const TG3D& tg,CH3D& ch) { ch.x = this->x*tg.mat[0][0]+ this->y*tg.mat[0][1]+ this->z*tg.mat[0][2]+ this->w*tg.mat[0][3]; ch.y = this->x*tg.mat[1][0]+ this->y*tg.mat[1][1]+ this->z*tg.mat[1][2]+ this->w*tg.mat[1][3]; ch.z = this->x*tg.mat[2][0]+ this->y*tg.mat[2][1]+ this->z*tg.mat[2][2]+ this->w*tg.mat[2][3]; ch.w = this->x*tg.mat[3][0]+ this->y*tg.mat[3][1]+ this->z*tg.mat[3][2]+ this->w*tg.mat[3][3]; } /* Methode d'affichage texte */ void CH3D::print(void) { printf("%10.4f %10.4f %10.4f %10.4f",x,y,z,w); }