home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / graphics / 14163 < prev    next >
Encoding:
Internet Message Format  |  1993-01-24  |  5.5 KB

  1. Xref: sparky comp.graphics:14163 comp.windows.x.pex:694 comp.graphics.opengl:272
  2. Newsgroups: comp.graphics,comp.windows.x.pex,comp.graphics.opengl
  3. Path: sparky!uunet!paladin.american.edu!gatech!swrinde!emory!sol.ctr.columbia.edu!The-Star.honeywell.com!umn.edu!csus.edu!netcom.com!levine
  4. From: levine@netcom.com (Ron Levine)
  5. Subject: Re: Row major or column major matrices?
  6. Message-ID: <1993Jan24.225547.22999@netcom.com>
  7. Organization: Netcom Online Communications Services (408-241-9760 login: guest)
  8. References: <1993Jan22.124249.3817@eye.com>
  9. Date: Sun, 24 Jan 1993 22:55:47 GMT
  10. Lines: 102
  11.  
  12. In article <1993Jan22.124249.3817@eye.com> erich@eye.com (Eric Haines) writes:
  13. >I feel vaguely like I'm in a twilight zone episode.  You know, like the ones
  14. >where some guy wakes up and finds that all the lettering is backwards and
  15. >everyone is left-handed.
  16. >
  17. >Someone was telling me that OpenGL allows only post-concatenation of matrices.
  18. >This seemed bass-ackwards, and after a few minutes reconfirming in my slow
  19. >turtle brain that you'd normally want pre-concatenation of matrices, I read
  20. >over the OpenGL manual page carefully.  Aha, they store matrices in
  21. >column-major form:
  22. >
  23. >    a0   a4   a8   a12    a typical    1  0  0 -2
  24. >    a1   a5   a9   a13    translation    0  1  0  5
  25. >    a2   a6   a10  a14    matrix -->    0  0  1  3
  26. >    a3   a7   a11  a15            0  0  0  1
  27. >
  28. >Me, I learned on my pappy's knee (well, actually, through Newman & Sproull) to
  29. >use row major matrices.  Up until today using column major matrices never
  30. >crossed my mind.  Anywell, ideas like "we only post-concatenate column major
  31. >matrices" translates into "we only pre-concatenate row major matrices".
  32. >Lovely, a new way to confuse computer graphics people (as if left vs.
  33. >right-handed coordinate systems weren't bad enough).  This is not a slam of
  34. >OpenGL - Phigs uses column major matrices, too!
  35. >
  36. >It's admittedly a minor point, and really just a notational difference - the
  37. >matrices are just the same, of course.  As long as you get the matrix elements
  38. >in the right order it doesn't matter to the computer.  It's just writing it
  39. >down on paper and presenting it is where the difference appears.
  40. >
  41. >Just out of curiosity, I looked at a few computer graphics books and whatnot
  42. >and how they presented 3D matrices.
  43. >
  44. >Row Major users:
  45. >
  46. >    Foley & VD (1st edition), Newman & Sproull, Graphics Gems series,
  47. >    Rogers books, Watt, Burger & Gillies, the Thalmanns, HP Starbase
  48. >
  49. >Column Major users:
  50. >
  51. >    Foley & VD & F & H (2nd edition), OpenGL, Phigs (and PEX, I assume)
  52. >
  53. >So Foley et al is the only book I could find that uses column-major matrices.
  54. >Weirder yet, the first edition of Foley & VD uses the row-major form, but then
  55. >the second edition goes to column-major form!  Evidently this book's second
  56. >edition made quite an impression (or maybe just reflects some new teaching
  57. >methods present at the time), since both OpenGL and PEX adopted it, in
  58. >contrast with the rest of the research and academic community who (seem to)
  59. >use row-major matrices.
  60. >
  61. >If you made it this far, take a minute and hit that "r" key and let me know
  62. >which form (if either) you prefer, where you learned it, and any other
  63. >insights you might have.  I'm interested to see if there's any correlation
  64. >with school, or age, or whatever.  I'll summarize to the net.
  65. >
  66. >Thanks, and not that I'm biased or anything, but dismemberment and death to all
  67. >column-major users,
  68. >
  69. >Eric Haines
  70.  
  71. Eric, I believe that your note is confusing two different 
  72. conventional distinctions.  
  73.  
  74. "Row-major" and "column-major", as I have understood the terms for 
  75. years, refer to how the matrices are stored in memory, not to how they 
  76. are used to represent transformations. That is, the terms distinguish 
  77. between the Fortran convention, in which the first subscript varies 
  78. most rapidly as memory address increases, and the C convention, in 
  79. which the second subscript varies most rapidly as memory address 
  80. increases.  Although your note refers to how matrices are stored, I 
  81. think you are really concerned with quite a different distinction, 
  82. namely, whether the matrix represents a linear transformation as a 
  83. left multiplier of column vectors or as a right multiplier of row 
  84. vectors.  Mathematicians sometimes distinguish these two conventions 
  85. as the "pre-fix" and "post-fix" conventions. 
  86.  
  87. Mathematicians have long been split into two camps, between pre-fix 
  88. and post-fix preferences.  Geometers and analysts have tended more to 
  89. the pre-fix convention--thus you learned in calculus that f(x) denotes 
  90. the value of a function f for a domain element x. Then, if you compose 
  91. two functions, (gf)(x) means g(f(x)), that is, first apply f then 
  92. apply g.  This corresponds to interpreting a matrix as a left 
  93. multiplier of column vectors.
  94.  
  95. But some schools of abstract algebraists logicians, and some authors 
  96. of computer graphics books, have insisted on the post-fix (x)f or xf.  
  97. I always work in the pre-fix convention when I have a choice, but this 
  98. is only because in the past most of my math professors and books have 
  99. used it and so it is a little more natural to me.  I especially prefer 
  100. it in computer graphics, which is inspired more by geometry than by 
  101. abstract algebra. 
  102.  
  103. But the two conventions are completely equivalent, and one should have 
  104. no difficulty in using either.  Of course it is important to know 
  105. which convention is used by any particular system with which you are 
  106. working.  And of course, the matrices may be stored in row-major or 
  107. column-major order for either convention of writing functional 
  108. expressions; that distinction tends to depend on the programming 
  109. language. 
  110.  
  111. Ron
  112.  
  113.  
  114.