set_matrix()

Set the current matrix to the one specified through the parameter source.

Examples

example picture for set_matrix()
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
import numpy as np


def setup():
    py5.size(100, 100, py5.P3D)
    py5.no_fill()
    matrix = np.array([[0.866025, 0, 0.5, 0],
                       [0, 1, 0, 0],
                       [-0.5, 0, 0.866025, -86.6025],
                       [0, 0, 0, 1]], dtype=np.float64)
    py5.set_matrix(matrix)
    py5.stroke(153)
    py5.box(50)

Description

Set the current matrix to the one specified through the parameter source. Inside the Processing code it will call reset_matrix() followed by apply_matrix(). This will be very slow because apply_matrix() will try to calculate the inverse of the transform, so avoid it whenever possible.

Underlying Java method: setMatrix

Syntax

set_matrix(source: NDArray[(2, 3), Float], /) -> None
set_matrix(source: NDArray[(4, 4), Float], /) -> None

Parameters

  • source: NDArray[(2, 3), Float] - transformation matrix data

  • source: NDArray[(4, 4), Float] - transformation matrix data

Updated on September 11, 2021 16:51:34pm UTC