5
\$\begingroup\$

Are there multiple valid definitions for what translate, rotate and scale do to the 4x4 matrix?

I bring up this question, because I have a simple webgl program that draws a square and does a few translate, rotate, and scale transformations. When I originally wrote the program I was using glMatrix v0.9.5. I upgraded the glMatrix to v2.2 and now the square is in a different position and rotation.

I'm fairly certain I correctly upgraded the program to use the new version, since the program was so small to begin with.

Regardless of what is happening to my program, I'm very interested to know if translate, rotate, and scale have a single universal definition or if different graphics engines / matrix libraries can have different definitions for what the transforms do.

Further details:

No transformations (origin is at the top left corner) enter image description here

The square program with the following transformations:

translate x: 250, y: 250, z: 0

rotate around Z axis angle: -90

enter image description here

Finally the square program with the following transformations:

translate x: 250, y: 250, z: 0

rotate around Z axis angle: -90

translate x: 150, y: 0, z: 0

enter image description here

\$\endgroup\$
10
  • \$\begingroup\$ Are the columns and rows swapped in your two different examples? If so, that's not really a change to the way the matrix works, but rather a change of order of operations. Sort of. \$\endgroup\$ Commented Dec 20, 2013 at 4:24
  • \$\begingroup\$ I'm fairly certain they are not swapped. I'm doing a translate, rotate, translate, and rotate to the square and I'm getting a different result with the new version of glMatrix. But if I just do a translate and then a rotate then both versions of glMatrix give the same result. \$\endgroup\$
    – Anton
    Commented Dec 20, 2013 at 4:28
  • 2
    \$\begingroup\$ Would you edit your question to include your input, the operations, and the different output? \$\endgroup\$ Commented Dec 20, 2013 at 4:49
  • 1
    \$\begingroup\$ Looks like possibly in the previous version, the second translate (150, 0, 0) was happening in the rotated coordinate system, i.e. the x-translate would be along the world space y-axis, but now the translate is being applied in world coordinates, so the x-translate is along the x-axis. That is strange, though - with the normal way of combining transforms by multiplying matrices, you would expect the former, i.e. the v0.9.5 behavior seems more correct. \$\endgroup\$ Commented Dec 20, 2013 at 5:33
  • 1
    \$\begingroup\$ Instead of or in addition to pictures, post some small code samples. There's a bazillion simple explanations for differing output from similar input. \$\endgroup\$ Commented Dec 20, 2013 at 7:37

1 Answer 1

1
\$\begingroup\$

I have discovered that the matrix library I am using (glMatrix) did in fact change how its mat4.translate works.

It seems that different people do have different ideas about what the transforms definitions are.

I opened up an issue on the glMatrix github page where it is being discussed more for those who are interested.

\$\endgroup\$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .