MCPcopy Create free account
hub / github.com/vispy/vispy / MatrixTransform

Class MatrixTransform

vispy/visuals/transforms/linear.py:316–551  ·  view source on GitHub ↗

Affine transformation class Parameters ---------- matrix : array-like | None 4x4 array to use for the transform.

Source from the content-addressed store, hash-verified

314
315
316class MatrixTransform(BaseTransform):
317 """Affine transformation class
318
319 Parameters
320 ----------
321 matrix : array-like | None
322 4x4 array to use for the transform.
323 """
324
325 glsl_map = """
326 vec4 affine_transform_map(vec4 pos) {
327 return $matrix * pos;
328 }
329 """
330
331 glsl_imap = """
332 vec4 affine_transform_imap(vec4 pos) {
333 return $inv_matrix * pos;
334 }
335 """
336
337 Linear = True
338 Orthogonal = False
339 NonScaling = False
340 Isometric = False
341
342 def __init__(self, matrix=None):
343 super(MatrixTransform, self).__init__()
344 if matrix is not None:
345 self.matrix = matrix
346 else:
347 self.reset()
348
349 @arg_to_vec4
350 def map(self, coords):
351 """Map coordinates
352
353 Parameters
354 ----------
355 coords : array-like
356 Coordinates to map.
357
358 Returns
359 -------
360 coords : ndarray
361 Coordinates.
362 """
363 # looks backwards, but both matrices are transposed.
364 return np.dot(coords, self.matrix)
365
366 @arg_to_vec4
367 def imap(self, coords):
368 """Inverse map coordinates
369
370 Parameters
371 ----------
372 coords : array-like
373 Coordinates to inverse map.

Callers 12

test_multiprogramFunction · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
_dist_to_transMethod · 0.85
as_matrixMethod · 0.85
__mul__Method · 0.85
test_gridlines_depthFunction · 0.85

Calls

no outgoing calls

Tested by 2

test_multiprogramFunction · 0.72
test_gridlines_depthFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…