void Matrix44::setRotation(double radians, Vector axis){ assert(axis.size() == 3); Matrix44 r = Matrix44(); Matrix44 aux = Matrix44();; aux.setIdentity(); aux.setPosition(m[3],m[7],m[11]); r.setRotationMatrix(radians, axis); operator=(r*aux); }
//--------------------- //For a local rotation you have to: //1. Put the Matrix at 0,0,0 world coordinates after memorizing the original position //2. Make a normal rotation //3. Put back Matrix to its original position //--------------------- void Matrix44::rotateLocal(double radians, Vector axis){ //1 Matrix44 r = Matrix44(); r.setRotationMatrix(radians,axis); Vector pos= Vector(3); pos.takePosition(*this); setPosition(0,0,0); //2 operator=(r*(*this)); //3 setPosition(pos[0], pos[1], pos[2]); }