The Surrican
The Surrican

Reputation: 29874

Whats the difference between these two java code snippets?

I have this code i am doing for university. The first code works as expected, the second one provides different results.

I can not see what they are doing differently??

first:

public Mat3 getNormalMatrix() {
    return new Mat3(this.getInverseMatrix()).transpose();
}

second:

public Mat3 getNormalMatrix() {
    Mat4 mat = this.getInverseMatrix();
    Mat3 bla = new Mat3(mat);
    bla.transpose();
    return bla;
}

Upvotes: 0

Views: 166

Answers (1)

Zeki
Zeki

Reputation: 5296

The first one returns the result of transpose() the second one returns bla.

In the second example, you want

bla = bla.transpose();

Upvotes: 10

Related Questions