/* nicolas.janey@univ-fcomte.fr */ /* Octobre 2005 */ /* Classe de gestion de rotations */ #include #include "Direction.h" #include "Rotation.h" static void calculMatrice(float a,Direction *nd,float m[4][4]) { a *= 0.017453292519943295769236907684886F; float c =(float) cos(a); float s =(float) sin(a); float x2 = nd->x*nd->x; float y2 = nd->y*nd->y; float z2 = nd->z*nd->z; float xy = nd->x*nd->y; float xz = nd->x*nd->z; float yz = nd->y*nd->z; float unmoinsc = 1.0F-c; m[0][0] = x2+c*(1-x2); m[0][1] = xy*unmoinsc-nd->z*s; m[0][2] = xz*unmoinsc+nd->y*s; m[1][0] = xy*unmoinsc+nd->z*s; m[1][1] = y2+c*(1-y2); m[1][2] = yz*unmoinsc-nd->x*s; m[2][0] = xz*unmoinsc-nd->y*s; m[2][1] = yz*unmoinsc+nd->x*s; m[2][2] = z2+c*(1-z2); } Rotation::Rotation(float a,float ax,float ay,float az) : Transformation() { Direction *nd = new Direction(ax,ay,az); nd->normalise(); calculMatrice(a,nd,m); delete(nd); } Rotation::Rotation(float a,Direction *d) : Transformation() { Direction *nd = new Direction(d); nd->normalise(); calculMatrice(a,nd,m); delete(nd); }