home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.graphics:14127 comp.windows.x.pex:691 comp.graphics.opengl:270
- Path: sparky!uunet!psinntp!eye!erich
- From: erich@eye.com (Eric Haines)
- Newsgroups: comp.graphics,comp.windows.x.pex,comp.graphics.opengl
- Subject: Row major or column major matrices?
- Message-ID: <1993Jan22.124249.3817@eye.com>
- Date: Fri, 22 Jan 93 17:42:48 GMT
- Sender: erich@eye.com (Eric Haines)
- Organization: 3D/EYE, Inc. Ithaca, NY
- Lines: 57
-
- I feel vaguely like I'm in a twilight zone episode. You know, like the ones
- where some guy wakes up and finds that all the lettering is backwards and
- everyone is left-handed.
-
- Someone was telling me that OpenGL allows only post-concatenation of matrices.
- This seemed bass-ackwards, and after a few minutes reconfirming in my slow
- turtle brain that you'd normally want pre-concatenation of matrices, I read
- over the OpenGL manual page carefully. Aha, they store matrices in
- column-major form:
-
- a0 a4 a8 a12 a typical 1 0 0 -2
- a1 a5 a9 a13 translation 0 1 0 5
- a2 a6 a10 a14 matrix --> 0 0 1 3
- a3 a7 a11 a15 0 0 0 1
-
- Me, I learned on my pappy's knee (well, actually, through Newman & Sproull) to
- use row major matrices. Up until today using column major matrices never
- crossed my mind. Anywell, ideas like "we only post-concatenate column major
- matrices" translates into "we only pre-concatenate row major matrices".
- Lovely, a new way to confuse computer graphics people (as if left vs.
- right-handed coordinate systems weren't bad enough). This is not a slam of
- OpenGL - Phigs uses column major matrices, too!
-
- It's admittedly a minor point, and really just a notational difference - the
- matrices are just the same, of course. As long as you get the matrix elements
- in the right order it doesn't matter to the computer. It's just writing it
- down on paper and presenting it is where the difference appears.
-
- Just out of curiosity, I looked at a few computer graphics books and whatnot
- and how they presented 3D matrices.
-
- Row Major users:
-
- Foley & VD (1st edition), Newman & Sproull, Graphics Gems series,
- Rogers books, Watt, Burger & Gillies, the Thalmanns, HP Starbase
-
- Column Major users:
-
- Foley & VD & F & H (2nd edition), OpenGL, Phigs (and PEX, I assume)
-
- So Foley et al is the only book I could find that uses column-major matrices.
- Weirder yet, the first edition of Foley & VD uses the row-major form, but then
- the second edition goes to column-major form! Evidently this book's second
- edition made quite an impression (or maybe just reflects some new teaching
- methods present at the time), since both OpenGL and PEX adopted it, in
- contrast with the rest of the research and academic community who (seem to)
- use row-major matrices.
-
- If you made it this far, take a minute and hit that "r" key and let me know
- which form (if either) you prefer, where you learned it, and any other
- insights you might have. I'm interested to see if there's any correlation
- with school, or age, or whatever. I'll summarize to the net.
-
- Thanks, and not that I'm biased or anything, but dismemberment and death to all
- column-major users,
-
- Eric Haines
-