public Matrix getRotationMatrix ( double theta ) { if ( rotationAxis == null ) { // special case for pure translational axes return Matrix . identity ( 3 , 3 ) ; } double x = rotationAxis . getX ( ) ; double y = rotationAxis . getY ( ) ; double z = rotationAxis . getZ ( ) ; double cos = Math . cos ( theta ) ; double sin = Math . sin ( theta ) ; double com = 1 - cos ; return new Matrix ( new double [ ] [ ] { { com * x * x + cos , com * x * y + sin * z , com * x * z + - sin * y } , { com * x * y - sin * z , com * y * y + cos , com * y * z + sin * x } , { com * x * z + sin * y , com * y * z - sin * x , com * z * z + cos } , } ) ; }
Get the rotation matrix corresponding to a rotation about this axis