parameters: (left, right, bottom, top, near, far, perspective=False)
return_statement: return numpy.array(M)
docstring: Return matrix to obtain normalized device coordinates from frustum.
  
      The frustum bounds are axis-aligned along x (left, right),
      y (bottom, top) and z (near, far).
  
      Normalized device coordinates are in range [-1, 1] if coordinates are
      inside the frustum.
  
      If perspective is True the frustum is a truncated pyramid with the
      perspective point at origin and direction along z axis, otherwise an
      orthographic canonical view volume (a box).
  
      Homogeneous coordinates transformed by the perspective clip matrix
      need to be dehomogenized (divided by w coordinate).
  
      >>> frustum = numpy.random.rand(6)
      >>> frustum[1] += frustum[0]
      >>> frustum[3] += frustum[2]
      >>> frustum[5] += frustum[4]
      >>> M = clip_matrix(perspective=False, *frustum)
      >>> numpy.dot(M, [frustum[0], frustum[2], frustum[4], 1])
      array([-1., -1., -1.,  1.])
      >>> numpy.dot(M, [frustum[1], frustum[3], frustum[5], 1])
      array([ 1.,  1.,  1.,  1.])
      >>> M = clip_matrix(perspective=True, *frustum)
      >>> v = numpy.dot(M, [frustum[0], frustum[2], frustum[4], 1])
      >>> v / v[3]
      array([-1., -1., -1.,  1.])
      >>> v = numpy.dot(M, [frustum[1], frustum[3], frustum[4], 1])
      >>> v / v[3]
      array([ 1.,  1., -1.,  1.])
docstring_summary: Return matrix to obtain normalized device coordinates from frustum.
docstring_tokens: Return matrix to obtain normalized device coordinates from frustum .
function: def clip_matrix(left, right, bottom, top, near, far, perspective=False):
      """Return matrix to obtain normalized device coordinates from frustum.
  
      The frustum bounds are axis-aligned along x (left, right),
      y (bottom, top) and z (near, far).
  
      Normalized device coordinates are in range [-1, 1] if coordinates are
      inside the frustum.
  
      If perspective is True the frustum is a truncated pyramid with the
      perspective point at origin and direction along z axis, otherwise an
      orthographic canonical view volume (a box).
  
      Homogeneous coordinates transformed by the perspective clip matrix
      need to be dehomogenized (divided by w coordinate).
  
      >>> frustum = numpy.random.rand(6)
      >>> frustum[1] += frustum[0]
      >>> frustum[3] += frustum[2]
      >>> frustum[5] += frustum[4]
      >>> M = clip_matrix(perspective=False, *frustum)
      >>> numpy.dot(M, [frustum[0], frustum[2], frustum[4], 1])
      array([-1., -1., -1.,  1.])
      >>> numpy.dot(M, [frustum[1], frustum[3], frustum[5], 1])
      array([ 1.,  1.,  1.,  1.])
      >>> M = clip_matrix(perspective=True, *frustum)
      >>> v = numpy.dot(M, [frustum[0], frustum[2], frustum[4], 1])
      >>> v / v[3]
      array([-1., -1., -1.,  1.])
      >>> v = numpy.dot(M, [frustum[1], frustum[3], frustum[4], 1])
      >>> v / v[3]
      array([ 1.,  1., -1.,  1.])
  
      """
      if left >= right or bottom >= top or near >= far:
          raise ValueError("invalid frustum")
      if perspective:
          if near <= _EPS:
              raise ValueError("invalid frustum: near <= 0")
          t = 2.0 * near
          M = [[t/(left-right), 0.0, (right+left)/(right-left), 0.0],
               [0.0, t/(bottom-top), (top+bottom)/(top-bottom), 0.0],
               [0.0, 0.0, (far+near)/(near-far), t*far/(far-near)],
               [0.0, 0.0, -1.0, 0.0]]
      else:
          M = [[2.0/(right-left), 0.0, 0.0, (right+left)/(left-right)],
               [0.0, 2.0/(top-bottom), 0.0, (top+bottom)/(bottom-top)],
               [0.0, 0.0, 2.0/(far-near), (far+near)/(near-far)],
               [0.0, 0.0, 0.0, 1.0]]
      return numpy.array(M)
function_tokens: def clip_matrix ( left , right , bottom , top , near , far , perspective = False ) : if left >= right or bottom >= top or near >= far : raise ValueError ( "invalid frustum" ) if perspective : if near <= _EPS : raise ValueError ( "invalid frustum: near <= 0" ) t = 2.0 * near M = [ [ t / ( left - right ) , 0.0 , ( right + left ) / ( right - left ) , 0.0 ] , [ 0.0 , t / ( bottom - top ) , ( top + bottom ) / ( top - bottom ) , 0.0 ] , [ 0.0 , 0.0 , ( far + near ) / ( near - far ) , t * far / ( far - near ) ] , [ 0.0 , 0.0 , - 1.0 , 0.0 ] ] else : M = [ [ 2.0 / ( right - left ) , 0.0 , 0.0 , ( right + left ) / ( left - right ) ] , [ 0.0 , 2.0 / ( top - bottom ) , 0.0 , ( top + bottom ) / ( bottom - top ) ] , [ 0.0 , 0.0 , 2.0 / ( far - near ) , ( far + near ) / ( near - far ) ] , [ 0.0 , 0.0 , 0.0 , 1.0 ] ] return numpy . array ( M )