# vispy.visuals.transforms.linear module

class vispy.visuals.transforms.linear.MatrixTransform(matrix=None)

  Bases: `BaseTransform`

  Affine transformation class

  Parameters:
    matrix array-like | None

      4x4 array to use for the transform.

  Isometric = False
  Linear = True
  NonScaling = False
  Orthogonal = False
  glsl_imap = '\n vec4 affine_transform_imap(vec4 pos) {\n return $inv_matrix * pos;\n }\n '
  glsl_map = '\n vec4 affine_transform_map(vec4 pos) {\n return $matrix * pos;\n }\n '
  imap(coords)

    Inverse map coordinates

    Parameters:
      coords array-like

        Coordinates to inverse map.

    Returns:
      coords ndarray

        Coordinates.

  property inv_matrix
  map(coords)

    Map coordinates

    Parameters:
      coords array-like

        Coordinates to map.

    Returns:
      coords ndarray

        Coordinates.

  property matrix
  reset()
  rotate(angle, axis)

    Rotate the matrix by some angle about a given axis.

    The rotation is applied after the transformations already present in the matrix.

    Parameters:
      angle float

        The angle of rotation, in degrees.

      axis array-like

        The x, y and z coordinates of the axis vector to rotate around.

  scale(scale, center=None)

    Scale the matrix about a given origin.

    The scaling is applied after the transformations already present in the matrix.

    Parameters:
      scale array-like

        Scale factors along x, y and z axes.

      center array-like or None

        The x, y and z coordinates to scale around. If None, (0, 0, 0) will be used.

  set_frustum(l, r, b, t, n, f)

    Set the frustum

    Parameters:
      l float

        Left.

      r float

        Right.

      b float

        Bottom.

      t float

        Top.

      n float

        Near.

      f float

        Far.

  set_mapping(points1, points2)

    Set to a 3D transformation matrix that maps points1 onto points2.

    Parameters:
      points1 array-like, shape (4, 3)

        Four starting 3D coordinates.

      points2 array-like, shape (4, 3)

        Four ending 3D coordinates.

  set_ortho(l, r, b, t, n, f)

    Set ortho transform

    Parameters:
      l float

        Left.

      r float

        Right.

      b float

        Bottom.

      t float

        Top.

      n float

        Near.

      f float

        Far.

  set_perspective(fov, aspect, near, far)

    Set the perspective

    Parameters:
      fov float

        Field of view.

      aspect float

        Aspect ratio.

      near float

        Near location.

      far float

        Far location.

  shader_imap()

    See shader_map.

  shader_map()

    Return a shader Function that accepts only a single vec4 argument and defines new attributes / uniforms supplying the Function with any static input.

  translate(pos)

    Translate the matrix

    The translation is applied after the transformations already present in the matrix.

    Parameters:
      pos arrayndarray

        Position to translate by.

class vispy.visuals.transforms.linear.NullTransform

  Bases: `BaseTransform`

  Transform having no effect on coordinates (identity transform).

  Isometric = True
  Linear = True
  NonScaling = True
  Orthogonal = True
  glsl_imap = 'vec4 null_transform_imap(vec4 pos) {return pos;}'
  glsl_map = 'vec4 null_transform_map(vec4 pos) {return pos;}'
  imap(coords)

    Inverse map coordinates

    Parameters:
      coords array-like

        Coordinates to inverse map.

  map(coords)

    Map coordinates

    Parameters:
      coords array-like

        Coordinates to map.

class vispy.visuals.transforms.linear.STTransform(scale=None, translate=None)

  Bases: `BaseTransform`

  Transform performing only scale and translate, in that order.

  Parameters:
    scale array-like

      Scale factors for X, Y, Z axes.

    translate array-like

      Scale factors for X, Y, Z axes.

  Isometric = False
  Linear = True
  NonScaling = False
  Orthogonal = True
  as_matrix()
  classmethod from_mapping(x0, x1)

    Create an STTransform from the given mapping

    See set_mapping for details.

    Parameters:
      x0 array-like

        Start.

      x1 array-like

        End.

    Returns:
      t instance of STTransform

        The transform.

  glsl_imap = '\n vec4 st_transform_imap(vec4 pos) {\n return vec4((pos.xyz - $translate.xyz * pos.w) / $scale.xyz,\n pos.w);\n }\n '
  glsl_map = '\n vec4 st_transform_map(vec4 pos) {\n return vec4(pos.xyz * $scale.xyz + $translate.xyz * pos.w, pos.w);\n }\n '
  imap(coords)

    Invert map coordinates

    Parameters:
      coords array-like

        Coordinates to inverse map.

    Returns:
      coords ndarray

        Coordinates.

  map(coords)

    Map coordinates

    Parameters:
      coords array-like

        Coordinates to map.

    Returns:
      coords ndarray

        Coordinates.

  move(move)

    Change the translation of this transform by the amount given.

    Parameters:
      move array-like

        The values to be added to the current translation of the transform.

  property scale
  set_mapping(x0, x1, update=True)

    Configure this transform such that it maps points x0 => x1

    Parameters:
      x0 array-like, shape (2, 2) or (2, 3)

        Start location.

      x1 array-like, shape (2, 2) or (2, 3)

        End location.

      update bool

        If False, then the update event is not emitted.

    Examples

    For example, if we wish to map the corners of a rectangle:

        >>> p1 = [[0, 0], [200, 300]]

    onto a unit cube:

        >>> p2 = [[-1, -1], [1, 1]]

    then we can generate the transform as follows:

        >>> tr = STTransform()
        >>> tr.set_mapping(p1, p2)
        >>> assert tr.map(p1)[:,:2] == p2  # test

  shader_imap()

    See shader_map.

  shader_map()

    Return a shader Function that accepts only a single vec4 argument and defines new attributes / uniforms supplying the Function with any static input.

  property translate
  zoom(zoom, center=(0, 0, 0), mapped=True)

    Update the transform such that its scale factor is changed, but the specified center point is left unchanged.

    Parameters:
      zoom array-like

        Values to multiply the transform’s current scale factors.

      center array-like

        The center point around which the scaling will take place.

      mapped bool

        Whether center is expressed in mapped coordinates (True) or unmapped coordinates (False).

previous

vispy.visuals.transforms.interactive module

next

vispy.visuals.transforms.nonlinear module