matrix_transform_vertex

This function transforms a vector by a matrix and returns the result as a new array.

It takes a transform matrix (as returned by the function matrix_build) and the x, y and z values of the vector to transform. It can optionally take the value of the w component.

The function returns an array of the same size as the number of components that you provide: 

 

Syntax:

matrix_transform_vertex(matrix, x, y, z, [w]);

ArgumentTypeDescription
matrixMatrix ArrayThe matrix to use
xRealThe x component of the vector to transform
yRealThe y component of the vector to transform
zRealThe z component of the vector to transform
wRealOPTIONAL The w component of the vector to transform

 

Returns:

Array (3 elements (x, y and z are passed) or 4 elements (x, y, z and w are passed))

 

Example:

t_matrix = matrix_build(0, 0, 0, 0, 90, 0, 1, 2, 1);
new_xyz = matrix_transform_vertex(t_matrix, x, y, z);

The above code transforms the given values using the matrix stored in the variable "t_matrix" and stores them in the array new_xyz.