def axisAndAngle2RotMatrix(axis, angle):
axis = np.asarray(axis)<EOL>angle = np.asarray(angle)<EOL>axis = axis/ np.sqrt(np.dot(axis, axis))<EOL>a = np.cos(angle/ <NUM_LIT:2>)<EOL>b, c, d = -axis * np.sin(angle/ <NUM_LIT:2>)<EOL>aa, bb, cc, dd = a * a, b * b, c * c, d * d<EOL>bc, ad, ac, ab, bd, cd = b * c, a * d, a * c, a * b, b * d, c * d<EOL>return np.array([[aa + bb - cc - dd, <NUM_LIT:2> * (bc + ad), <NUM_LIT:2> * (bd - ac)],<EOL>[<NUM_LIT:2> * (bc - ad), aa + cc - bb - dd, <NUM_LIT:2> * (cd + ab)],<EOL>[<NUM_LIT:2> * (bd + ac), <NUM_LIT:2> * (cd - ab), aa + dd - bb - cc]])<EOL>
http://stackoverflow.com/questions/6802577/python-rotation-of-3d-vector

Return the rotation matrix associated with counterclockwise rotation about
the given axis by angle radians.