Multiple mat4 by vec4 and then make it vec3 in Python

Viewed 221

Please help me. How can I multiply mat4 by mat4 and then make it vec3 in Python? Here is an example of what I need in C++:

glm::vec3 var = glm::vec3((mat4(...)* glm::vec4(0, 0, 0, 1)));

As well as a failed attempt on Python:

var=pyrr.Vector3( pyrr.matrix44.create_from_translation(pyrr.Vector3([20,0,5])) * pyrr.Vector4([0,0,0,1]))

1 Answers

Use the @ operator.

var=(pyrr.matrix44.create_from_translation(pyrr.Vector3([20,0,5])).T @ pyrr.Vector4([0,0,0,1])).xyz

The @ operator is described in PEP-465

Related