pyvista.Transform.scale

pyvista.Transform.scale#

Transform.scale(
*factor,
point: VectorLike[float] | None = None,
multiply_mode: Literal['pre', 'post'] | None = None,
) Transform[source]#

Concatenate a scale matrix.

Create a scale matrix and concatenate() it with the current transformation matrix according to pre-multiply or post-multiply semantics.

Internally, the matrix is stored in the matrix_list.

Parameters:
*factorfloat | VectorLike[float]

Scale factor(s) to use. Use a single number for uniform scaling or three numbers for non-uniform scaling.

pointVectorLike[float], optional

Point to scale from. By default, the object’s point is used, but this can be overridden. If set, two additional transformations are concatenated and added to the matrix_list:

multiply_mode‘pre’ | ‘post’, optional

Multiplication mode to use when concatenating the matrix. By default, the object’s multiply_mode is used, but this can be overridden. Set this to 'pre' for pre-multiplication or 'post' for post-multiplication.

See also

pyvista.DataSet.scale()

Scale a mesh.

Examples

Concatenate a scale matrix.

>>> import pyvista as pv
>>> transform = pv.Transform().scale(1, 2, 3)
>>> transform.matrix
array([[1., 0., 0., 0.],
       [0., 2., 0., 0.],
       [0., 0., 3., 0.],
       [0., 0., 0., 1.]])

Concatenate a second scale matrix using *.

>>> transform = transform * 2
>>> transform.matrix
array([[2., 0., 0., 0.],
       [0., 4., 0., 0.],
       [0., 0., 6., 0.],
       [0., 0., 0., 1.]])

Scale from a point. Check the matrix_list to see that a translation is added before and after the scaling.

>>> transform = pv.Transform().scale(7, point=(1, 2, 3))
>>> translation_to_origin = transform.matrix_list[0]
>>> translation_to_origin
array([[ 1.,  0.,  0., -1.],
       [ 0.,  1.,  0., -2.],
       [ 0.,  0.,  1., -3.],
       [ 0.,  0.,  0.,  1.]])
>>> scale = transform.matrix_list[1]
>>> scale
array([[7., 0., 0., 0.],
       [0., 7., 0., 0.],
       [0., 0., 7., 0.],
       [0., 0., 0., 1.]])
>>> translation_from_origin = transform.matrix_list[2]
>>> translation_from_origin
array([[1., 0., 0., 1.],
       [0., 1., 0., 2.],
       [0., 0., 1., 3.],
       [0., 0., 0., 1.]])