Fixed calculation bug in 3d rotation