parameters: (angle, direction, point=None)
return_statement: return M
docstring: Return matrix to rotate about axis defined by point and direction.
  
      >>> angle = (random.random() - 0.5) * (2*math.pi)
      >>> direc = numpy.random.random(3) - 0.5
      >>> point = numpy.random.random(3) - 0.5
      >>> R0 = rotation_matrix(angle, direc, point)
      >>> R1 = rotation_matrix(angle-2*math.pi, direc, point)
      >>> is_same_transform(R0, R1)
      True
      >>> R0 = rotation_matrix(angle, direc, point)
      >>> R1 = rotation_matrix(-angle, -direc, point)
      >>> is_same_transform(R0, R1)
      True
      >>> I = numpy.identity(4, numpy.float64)
      >>> numpy.allclose(I, rotation_matrix(math.pi*2, direc))
      True
      >>> numpy.allclose(2., numpy.trace(rotation_matrix(math.pi/2,
      ...                                                direc, point)))
      True
docstring_summary: Return matrix to rotate about axis defined by point and direction.
docstring_tokens: Return matrix to rotate about axis defined by point and direction .
function: def rotation_matrix(angle, direction, point=None):
      """Return matrix to rotate about axis defined by point and direction.
  
      >>> angle = (random.random() - 0.5) * (2*math.pi)
      >>> direc = numpy.random.random(3) - 0.5
      >>> point = numpy.random.random(3) - 0.5
      >>> R0 = rotation_matrix(angle, direc, point)
      >>> R1 = rotation_matrix(angle-2*math.pi, direc, point)
      >>> is_same_transform(R0, R1)
      True
      >>> R0 = rotation_matrix(angle, direc, point)
      >>> R1 = rotation_matrix(-angle, -direc, point)
      >>> is_same_transform(R0, R1)
      True
      >>> I = numpy.identity(4, numpy.float64)
      >>> numpy.allclose(I, rotation_matrix(math.pi*2, direc))
      True
      >>> numpy.allclose(2., numpy.trace(rotation_matrix(math.pi/2,
      ...                                                direc, point)))
      True
  
      """
      sina = math.sin(angle)
      cosa = math.cos(angle)
      direction = unit_vector(direction[:3])
      # rotation matrix around unit vector
      R = numpy.array(((cosa, 0.0,  0.0),
                       (0.0,  cosa, 0.0),
                       (0.0,  0.0,  cosa)), dtype=numpy.float64)
      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)),
                       dtype=numpy.float64)
      M = numpy.identity(4)
      M[:3, :3] = R
      if point is not None:
          # rotation not around origin
          point = numpy.array(point[:3], dtype=numpy.float64, copy=False)
          M[:3, 3] = point - numpy.dot(R, point)
      return M
function_tokens: def rotation_matrix ( angle , direction , point = None ) : sina = math . sin ( angle ) cosa = math . cos ( angle ) direction = unit_vector ( direction [ : 3 ] ) # rotation matrix around unit vector R = numpy . array ( ( ( cosa , 0.0 , 0.0 ) , ( 0.0 , cosa , 0.0 ) , ( 0.0 , 0.0 , cosa ) ) , dtype = numpy . float64 ) 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 ) ) , dtype = numpy . float64 ) M = numpy . identity ( 4 ) M [ : 3 , : 3 ] = R if point is not None : # rotation not around origin point = numpy . array ( point [ : 3 ] , dtype = numpy . float64 , copy = False ) M [ : 3 , 3 ] = point - numpy . dot ( R , point ) return M