Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use matrix.preScale(x,y)

How does the function matrix.preScale(x,y) work and how is it used?

Example usage:

matrix.preScale(1.0f, 1.0f);
like image 832
Khiem Khiem Avatar asked Mar 01 '12 06:03

Khiem Khiem


1 Answers

The pre-, post- functions are used for pre- and post-multiplication respectively.

For example, call the following functions:

reset(); //reset to identity matrix
setRotate(90); //set the matrix to be a 90 degree rotation
preScale(2.0f,2.0f); //scale uniformly with factor 2

or

reset(); //reset to identity matrix
setRotate(90); //set the matrix to be a 90 degree rotation
postScale(2.0f,2.0f); //scale uniformly with factor 2

Now, what's the difference?

In the first version, the final matrix first scales and then rotates. In the second, it's vice versa.

Pre functions construct a matrix and multiply it from right to the existing matrix post functions multiply from left.

like image 178
D-rk Avatar answered Oct 05 '22 12:10

D-rk