# Last Matrix operation ignored?

I have 2 methods, one to rotate my Quad and one to flip it (using scaleM), they are as follows: (Note, all values in these methods have been properly defined).

If I call just one, they work as expected, but if I call both, then only the one that is called last if applied - why is this? If I combine them into on 'flip and rotate method' - then my quad is both flipped and rotated. (See third code snippet)

Why is this?

Method to rotate

    public void rotate(float x, float y, int angle){

Matrix.setIdentityM(mRotationMatrix, 0);
Matrix.translateM(mRotationMatrix, 0, centreX, centreY, 0f);
Matrix.rotateM(mRotationMatrix, 0, -angle, 0, 0, 0.1f);
Matrix.translateM(mRotationMatrix, 0, -centreX, -centreY, 0f);

}


Method to 'flip' (horizontally)

    public void flipHorizontal(float x, float y){

Matrix.setIdentityM(mRotationMatrix, 0);
Matrix.translateM(mRotationMatrix, 0, centreX, centreY, 0f);
Matrix.scaleM(mRotationMatrix, 0, -1, 1, 0f);
Matrix.translateM(mRotationMatrix, 0, -centreX, -centreY, 0f);
}


Combined method

    public void flipHorizontal(float x, float y, int angle){

Matrix.setIdentityM(mRotationMatrix, 0);
Matrix.translateM(mRotationMatrix, 0, centreX, centreY, 0f);
Matrix.rotateM(mRotationMatrix, 0, angle, 0, 0, 0.1f);
Matrix.scaleM(mRotationMatrix, 0, -1, 1, 0f);
Matrix.translateM(mRotationMatrix, 0, -centreX, -centreY, 0f);

}

• A downvote with no explanation. This helps nobody. What's the point of it? Aug 13 '13 at 23:46