home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.graphics:14163 comp.windows.x.pex:694 comp.graphics.opengl:272
- Newsgroups: comp.graphics,comp.windows.x.pex,comp.graphics.opengl
- Path: sparky!uunet!paladin.american.edu!gatech!swrinde!emory!sol.ctr.columbia.edu!The-Star.honeywell.com!umn.edu!csus.edu!netcom.com!levine
- From: levine@netcom.com (Ron Levine)
- Subject: Re: Row major or column major matrices?
- Message-ID: <1993Jan24.225547.22999@netcom.com>
- Organization: Netcom Online Communications Services (408-241-9760 login: guest)
- References: <1993Jan22.124249.3817@eye.com>
- Date: Sun, 24 Jan 1993 22:55:47 GMT
- Lines: 102
-
- In article <1993Jan22.124249.3817@eye.com> erich@eye.com (Eric Haines) writes:
- >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
-
- Eric, I believe that your note is confusing two different
- conventional distinctions.
-
- "Row-major" and "column-major", as I have understood the terms for
- years, refer to how the matrices are stored in memory, not to how they
- are used to represent transformations. That is, the terms distinguish
- between the Fortran convention, in which the first subscript varies
- most rapidly as memory address increases, and the C convention, in
- which the second subscript varies most rapidly as memory address
- increases. Although your note refers to how matrices are stored, I
- think you are really concerned with quite a different distinction,
- namely, whether the matrix represents a linear transformation as a
- left multiplier of column vectors or as a right multiplier of row
- vectors. Mathematicians sometimes distinguish these two conventions
- as the "pre-fix" and "post-fix" conventions.
-
- Mathematicians have long been split into two camps, between pre-fix
- and post-fix preferences. Geometers and analysts have tended more to
- the pre-fix convention--thus you learned in calculus that f(x) denotes
- the value of a function f for a domain element x. Then, if you compose
- two functions, (gf)(x) means g(f(x)), that is, first apply f then
- apply g. This corresponds to interpreting a matrix as a left
- multiplier of column vectors.
-
- But some schools of abstract algebraists logicians, and some authors
- of computer graphics books, have insisted on the post-fix (x)f or xf.
- I always work in the pre-fix convention when I have a choice, but this
- is only because in the past most of my math professors and books have
- used it and so it is a little more natural to me. I especially prefer
- it in computer graphics, which is inspired more by geometry than by
- abstract algebra.
-
- But the two conventions are completely equivalent, and one should have
- no difficulty in using either. Of course it is important to know
- which convention is used by any particular system with which you are
- working. And of course, the matrices may be stored in row-major or
- column-major order for either convention of writing functional
- expressions; that distinction tends to depend on the programming
- language.
-
- Ron
-
-
-