numpy矩阵4x4 @ Nx4

时间:2020-08-10 18:39:55

标签: python numpy matrix

我正在尝试将世界变换应用于numpy矩阵。但是,我似乎找不到一种简单的方法来执行Nx4向量的4x4矩阵乘法,其中N是顶点数。

我都尝试过 Nx4x4 @ Nx4 4x4 @ Nx4 乘法。当然,我可以明智地做到这一点,但我希望有一种更聪明的方法来做到这一点。

vertices = np.ones([VERTEX_COUNT, 4])
vertices[:, 0:3] = vertex_map[element.path_vertices]
matrix = np.full([VERTEX_COUNT, 4, 4], np.reshape(element.matrix, [4, 4]))

transformed = matrix @ vertices # dimension mismatch

# i would rather not do this
# matrix = np.reshape(element.matrix, [4, 4])
# transformed = np.array([matrix @ vertex for vertex in vertices])

0 个答案:

没有答案
相关问题