I have a texture, some 2D vertices, and a matrix. The matrix is used to calculate the texture coordinates for each vertex, but the problem is that the matrix comes with absolutely no documentation and I'm having trouble working out how to calculate the texture coords correctly. I have it partially working.

The matrix is in this format:

sx rx tx
ry sy ty

Where s means "scale", r means "rotate", and t means "translate".

If the matrix doesn't contain any rotation (i.e. ry = rx = 0), I can correctly calculate the texture coordinates u and v like this:

u = x/sx - tx
v = y/sy - ty

But I can't figure out how to put rx and ry into the equation and get the correct results. Normal matrix multiplication involves multiplying and adding but this one involves dividing and subtracting, so I know I'm missing something but I don't know what it is.

Here is one of the matrices with rotation:

26.191574096679688   7.0180206298828125  1579
-7.0180206298828125  26.191574096679688  1879

Here is one of the matrices without rotation:

27.115478515625  0                1867
0                27.115478515625  800 
  • \$\begingroup\$ For 2D coordinates with rotations you need a 3x3 matrix, not a 3x2 matrix. So where's the last part? :) \$\endgroup\$
    – Roy T.
    Aug 25, 2012 at 9:29
  • 1
    \$\begingroup\$ It's assumed to be 0, 0, 1 I guess. \$\endgroup\$ Aug 25, 2012 at 9:30
  • \$\begingroup\$ Plus, rotation only requires a 2x2 matrix. Translation requires a 3x3 matrix. \$\endgroup\$ Aug 25, 2012 at 9:37
  • \$\begingroup\$ It is x*sx not x/sx, and it is +tx*1 not -tx*1 you might want to lookup matrix vector multiplication on wikipedia \$\endgroup\$ Aug 25, 2012 at 9:47
  • \$\begingroup\$ @Maik that gives incorrect results. It's not a straight matrix multiplication. Please read the question before commenting. \$\endgroup\$ Aug 25, 2012 at 9:53

1 Answer 1


As analyzed in the comments, the matrix was the inverse matrix. Inverting it gives the correct results. Here is the first example from the question:

scale = 27.115515  rot = -15 deg   trans = {1579, 1879}

26.191574096679688   7.0180206298828125  1579
-7.0180206298828125  26.191574096679688  1879

the inverse matrix to use is:

0.0356226228  -0.0095450654   -38.3129425048
0.0095450654   0.0356226228   -82.0065689086

You must log in to answer this question.

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