Anton Boritskiy
Anton Boritskiy

Reputation: 1569

Is there any difference between Matrix.setRotateM and Matrix.rotateM

There are two methods to rotate matrices in android.opengl.Matrix class, they are:

  1. static void rotateM (float[] m, int mOffset, float a, float x, float y, float z)
    Rotates matrix m in place by angle a (in degrees) around the axis (x, y, z)

  2. static void setRotateM(float[] rm, int rmOffset, float a, float x, float y, float z)
    Rotates matrix m by angle a (in degrees) around the axis (x, y, z)

Here is the original ducumentation

These methods act a bit different, but I don't understand the exact difference. Coul you explain this to me?

Upvotes: 4

Views: 5070

Answers (1)

Mārtiņš Možeiko
Mārtiņš Možeiko

Reputation: 12927

Let's say matrix R is rotation matrix around (x,y,z) axis by angle a, then rotateM method modifies existing matrix m like this: m = R * m, but setRotateM overwrites it: m = R.

Upvotes: 6

Related Questions