/* Mathematiques de l'informatique graphique */ /* Coordonnees homogenes en 3D */ /* */ /* Auteur: Nicolas JANEY */ /* nicolas.janey@univ-fcomte.fr */ /* Mars 2019 */ #include #include #include #include "CH3D.h" /* Constructeurs */ CH3D::CH3D(void) { v.x = v.y = v.z = 0.0; v.w = 1.0; } CH3D::CH3D(double x,double y,double z,double w) { v.x = x; v.y = y; v.z = z; v.w = w; } CH3D::CH3D(CH3D *ch) { v.x = ch->v.x; v.y = ch->v.y; v.z = ch->v.z; v.w = ch->v.w; } /* Destructeur */ CH3D::~CH3D(void) { } /* Getters */ double CH3D::getx(void) { return v.x; } double CH3D::gety(void) { return v.y; } double CH3D::getz(void) { return v.z; } double CH3D::getw(void) { return v.w; } bool CH3D::get(int i,double *val) { if ( ( i >= 0 ) && ( i < 4 ) ) { *val = v.c[i]; return true; } return false; } /* Setters */ bool CH3D::setx(double x) { v.x = x; return true; } bool CH3D::sety(double y) { v.y = y; return true; } bool CH3D::setz(double z) { v.z = z; return true; } bool CH3D::setw(double w) { v.w = w; return true; } bool CH3D::set(double val,int i) { if ( ( i >= 0 ) && ( i < 4 ) ) { v.c[i] = val; return true; } return false; } /* Methode d'affichage texte */ void CH3D::print(void) { printf("%10.4lf %10.4lf %10.4lf %10.4lf",v.x,v.y,v.z,v.w); }