pyvista.Light.transform_matrix#

property Light.transform_matrix[source]#

Return (if any) or set the transformation matrix of the light.

The transformation matrix is None by default, and it is stored as a vtk.vtkMatrix4x4 object when set. If set, the light’s parameters (position and focal point) are transformed by the matrix before being rendered. See also the world_position and world_focal_point read-only properties that can differ from position and focal_point, respectively.

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.

Examples

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)