Affine transformation class Parameters ---------- matrix : array-like | None 4x4 array to use for the transform.
| 314 | |
| 315 | |
| 316 | class 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. |
no outgoing calls
searching dependent graphs…