如何在 Python 处理中将自定义矩阵添加到矩阵转换堆栈?

How do I add a custom matrix to the matrix transformation stack in Python Processing?

我正在使用 Python 处理。我有一个自定义矩阵,我想将其添加到当前矩阵转换堆栈中,而不必先费心将矩阵分解为 rotateX() rotateY() 等

如何指定自己的矩阵并应用它?

回答此类问题的最佳方法是查看 the reference

听起来您正在寻找 applyMatrix() 函数:

size(100, 100, P3D);
noFill();
translate(50, 50, 0);
rotateY(PI/6); 
stroke(153);
box(35);
// Set rotation angles
float ct = cos(PI/9.0);
float st = sin(PI/9.0);          
// Matrix for rotation around the Y axis
applyMatrix(  ct, 0.0,  st,  0.0,
             0.0, 1.0, 0.0,  0.0,
             -st, 0.0,  ct,  0.0,
             0.0, 0.0, 0.0,  1.0);  
stroke(255);
box(50);


(source: processing.org)

Multiplies the current matrix by the one specified through the parameters. This is very slow because it will try to calculate the inverse of the transform, so avoid it whenever possible. The equivalent function in OpenGL is glMultMatrix().

等效的 Processing.py 引用是 here