PDA

View Full Version : vec3(vec4(vertex, 1));?????



a-sylum
07-19-2015, 07:27 AM
can i do vec3( matrixrotation * vec4(vertex, 1)); to get a vec3? matrixrotation is a 4x4 matrix. thanks :)

GClements
07-19-2015, 08:07 AM
can i do vec3( matrixrotation * vec4(vertex, 1)); to get a vec3? matrixrotation is a 4x4 matrix. thanks :)
Yes. For a rotation, you can also use mat3x3(matrixrotation) * vertex. But that's only equivalent if the matrix has no translation component.

If you want to specifically ignore the translation component (e..g. if you're transforming a direction rather than a position), you can use the mat3x3() approach or set the fourth component of the vector to zero rather than one.