我正在使用 Python 处理。我有一个自定义矩阵,我想将其添加到当前的矩阵转换堆栈中,而不必首先费心将矩阵分解为rotateX()rotateY()等。
如何指定我自己的矩阵并应用它?
回答此类问题的最佳方法是查看参考资料。
听起来你正在寻找这个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);
将当前矩阵乘以通过参数指定的矩阵。这很慢,因为它将尝试计算变换的逆数,因此请尽可能避免使用它。OpenGL 中的等效函数是 glMultMatrix()。
等效的 Processing.py 参考在这里。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句