Khiem Khiem
Khiem Khiem

Reputation: 107

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);

Upvotes: 5

Views: 6953

Answers (1)

D-rk
D-rk

Reputation: 5919

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.

Upvotes: 8

Related Questions