- property Light.transform_matrix¶
Return the transformation matrix of the light (if any).
The transformation matrix is
Noneby default, and it is stored as a
vtk.vtkMatrix4x4object when set. If set, the light’s parameters (position and focal point) are transformed by the matrix before being rendered. See also the
world_focal_pointread-only properties that can differ from
The 4-by-4 transformation matrix is a tool to encode a general linear transformation and a translation (an affine transform). The 3-by-3 principal submatrix (the top left corner of the matrix) encodes a three-dimensional linear transformation (e.g. some rotation around the origin). The top three elements in the last column of the matrix encode a three-dimensional translation. The last row of the matrix is redundant.
Create a light with a transformation matrix that corresponds to a 90-degree rotation around the z axis and a shift by (0, 0, -1), and check that the light’s position transforms as expected.
>>> import numpy as np >>> import pyvista as pv >>> light = pv.Light(position=(1, 0, 3)) >>> trans = np.zeros((4, 4)) >>> trans[:-1, :-1] = [[0, -1, 0], [1, 0, 0], [0, 0, 1]] >>> trans[:-1, -1] = [0, 0, -1] >>> light.transform_matrix = trans >>> light.position (1.0, 0.0, 3.0) >>> light.world_position (0.0, 1.0, 2.0)