/* Mathematiques de l'informatique graphique */ /* Transformation de visualisation */ /* en perspective */ /* */ /* Auteur: Nicolas JANEY */ /* nicolas.janey@univ-fcomte.fr */ /* Octobre 2011 */ #include #include #include #include "TransformationGeometrique.h" #include "ProjectionPerspective.h" #include "Position3D.h" #include "Direction3D.h" ProjectionPerspective::ProjectionPerspective(Position3D *po,Position3D *pv,double d):TransformationGeometrique() { Direction3D n(po,pv); n.normalisation(); double a = 1.0/sqrt(1.0-n.c[1]*n.c[1]); c[0][0] = -a*n.c[2]; c[0][1] = 0.0; c[0][2] = a*n.c[0]; c[0][3] = a*(po->c[0]*n.c[2]-po->c[2]*n.c[0]); c[1][0] = -a*n.c[0]*n.c[1]; c[1][1] = 1.0/a; c[1][2] = -a*n.c[1]*n.c[2]; c[1][3] = a*n.c[1]*(po->c[0]*n.c[0]+po->c[2]*n.c[2])-po->c[1]/a; c[2][0] = -n.c[0]; c[2][1] = -n.c[1]; c[2][2] = -n.c[2]; c[2][3] = po->c[0]*n.c[0]+po->c[1]*n.c[1]+po->c[2]*n.c[2]; c[3][0] = c[2][0]/d; c[3][1] = c[2][1]/d; c[3][2] = c[2][2]/d; c[3][3] = c[2][3]/d; } ProjectionPerspective::~ProjectionPerspective(void) { } void ProjectionPerspective::transforme(CoordonneesHomogenes *ch) { TransformationGeometrique::transforme(ch); ch->c[0] /= ch->c[3]; ch->c[1] /= ch->c[3]; }