gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Translation matrix

#168648 - Echo49 - Wed May 13, 2009 4:50 am

At gbatek the translation matrix is identified as:
Code:
 _  Translation Matrix   _
|  1.0   0     0     0    |
|  0     1.0   0     0    |
|  0     0     1.0   0    |
|_m[0]  m[1]  m[2]   1.0 _|

Shouldn't the translation vector be on the far right of the matrix instead?

#168650 - Dwedit - Wed May 13, 2009 6:39 am

If the coordinate is a column, translation goes on the right
If the coordinate is a row, translation goes on the bottom, and the translation matrix is Right Multiplied with the coordinate instead of Left Multiplied.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."


Last edited by Dwedit on Wed May 13, 2009 6:41 am; edited 1 time in total

#168651 - sajiimori - Wed May 13, 2009 6:39 am

@Echo49:

On column-major systems, yes, but not on the DS.

(Do I have that right? As I recall, DirectX is column-major and OpenGL is row-major...?)

#168652 - Cearn - Wed May 13, 2009 9:03 am

sajiimori wrote:
(Do I have that right? As I recall, DirectX is column-major and OpenGL is row-major...?)
Technically, it's only a notational difference. Most math and OpenGL books will use column-major notation, whereas DirectX uses row-major. In memory, the order of the elements are the same. It's just that C uses row-major as well, so OpenGL matrices don't translate directly to C-matrices.

If the coordinate vectors are columns, the matrix will be column-major, and when the vectors are rows, the matrix is row-major.
Code:

           A      ?  X    = (      X^T    ?      A^T         )^T
           
 ________________   ___      /              _______________  \ T
| ux  vx  wx  tx | | x |    |   _________  | ux  uy  uz  0 |  |               
| uy  vy  wy  ty |?| y |  = |  | x y z 1 |?| vx  vy  vz  0 |  |
| uz  vz  wz  tz | | z |    |   ---------  | wx  wy  wz  0 |  |               
|  0   0   0   d | | 1 |    |              | tx  ty  tz  d |  |
 ----------------   ---      \              ---------------   /

#168655 - Echo49 - Wed May 13, 2009 11:54 am

Ah I see.

I was getting confused wondering how in the world that would help translate the vectors.

Thanks!