使用 PyGLM 或 NumPy 翻译 python 中 vmath 等效语句的方法
translate method of vmath equivalent statement in python using PyGLM or NumPy
在 Python 中使用 NumPy or pyGLM 中的等效语句是什么?
vmath::translate(0.0f, 0.0f, -4.0f) * vmath::translate(1.2f, 2.2f, -1.0f)
这是一个较大的语句块,我很难将其转换为 Python,因为我不熟悉这两个库。搜索和手册对我来说收效甚微。
vmath::mat4 mv_matrix = vmath::translate(0.0f, 0.0f, -4.0f) *
vmath::translate(sinf(2.1f * f) * 0.5f,
cosf(1.7f * f) * 0.5f,
sinf(1.3f * f) * cosf(1.5f * f) * 2.0f) *
vmath::rotate((float)currentTime * 45.0f, 0.0f, 1.0f, 0.0f) *
vmath::rotate((float)currentTime * 81.0f, 1.0f, 0.0f, 0.0f);
如果我也可以问。 vmath::rotate() 在 Python 中的等价物是什么?谢谢。
import numpy.matlib
import numpy as np
a = np.array([0.0, 0.0, -4.0])
b = np.array([1.2, 2.2, 1.0])
product = np.dot(a,b)
print product
对于轮换,你可以选择这个答案
在 Python 中使用 NumPy or pyGLM 中的等效语句是什么?
vmath::translate(0.0f, 0.0f, -4.0f) * vmath::translate(1.2f, 2.2f, -1.0f)
这是一个较大的语句块,我很难将其转换为 Python,因为我不熟悉这两个库。搜索和手册对我来说收效甚微。
vmath::mat4 mv_matrix = vmath::translate(0.0f, 0.0f, -4.0f) *
vmath::translate(sinf(2.1f * f) * 0.5f,
cosf(1.7f * f) * 0.5f,
sinf(1.3f * f) * cosf(1.5f * f) * 2.0f) *
vmath::rotate((float)currentTime * 45.0f, 0.0f, 1.0f, 0.0f) *
vmath::rotate((float)currentTime * 81.0f, 1.0f, 0.0f, 0.0f);
如果我也可以问。 vmath::rotate() 在 Python 中的等价物是什么?谢谢。
import numpy.matlib
import numpy as np
a = np.array([0.0, 0.0, -4.0])
b = np.array([1.2, 2.2, 1.0])
product = np.dot(a,b)
print product
对于轮换,你可以选择这个答案