def rotation_matrix(angle, direction, point=None):
 sina = math.sin(angle)
 cosa = math.cos(angle)
 direction = unit_vector(direction[:3])
 R = numpy.diag([cosa, cosa, cosa])
 R += (numpy.outer(direction, direction) * (1.0 - cosa))
 direction *= sina
 R += numpy.array([[0.0, (- direction[2]), direction[1]], [direction[2], 0.0, (- direction[0])], [(- direction[1]), direction[0], 0.0]])
 M = numpy.identity(4)
 M[:3, :3] = R
 if (point is not None):
  point = numpy.array(point[:3], dtype=numpy.float64, copy=False)
  M[:3, 3] = (point - numpy.dot(R, point))
 return M

def rotation_matrix ( angle , direction , point = None ) : sina = math . sin ( angle ) cosa = math . cos ( angle ) direction = unit_vector ( direction [ : 3 ] ) R = numpy . diag ( [ cosa , cosa , cosa ] ) R += ( numpy . outer ( direction , direction ) * ( 1.0 - cosa ) ) direction *= sina R += numpy . array ( [ [ 0.0 , ( - direction [ 2 ] ) , direction [ 1 ] ] , [ direction [ 2 ] , 0.0 , ( - direction [ 0 ] ) ] , [ ( - direction [ 1 ] ) , direction [ 0 ] , 0.0 ] ] ) M = numpy . identity ( 4 ) M [ : 3 , : 3 ] = R if ( point is not None ) : point = numpy . array ( point [ : 3 ] , dtype = numpy . float64 , copy = False ) M [ : 3 , 3 ] = ( point - numpy . dot ( R , point ) ) return M
return matrix to rotate about axis defined by point and direction .