Re: Matrix order

New Message Reply Date view Thread view Subject view Author view

Don Hatch (hatch++at++hell.engr.sgi.com)
Fri, 17 Sep 1999 12:59:11 -0700


On Sep 17, 12:30pm, Scott Herod wrote:
> Subject: Re: Matrix order
> I think the confusion is with the names of the various pfMatrix
> routines. For example does postRot( M, d, x, y, z ) mean compute
> M*R where R is the rotation matrix or R*M? I am writing the matrix
> multiplication right to left as is standard so that M*R means first
> rotate then apply M.

Regardless of row/column convention,
"post" always means apply the incremental operation
"after" the current cumulative transform
(i.e., intuitively, on the "world space" side of the cumulative transform
rather than the "local space" side).

So in Performer documentation and API
(which uses row vectors and left-to-right concatenation),
post-multiplying by a rotation R means M*R,
and to apply the result to a vertex (row vector) v you would write v*M*R.

But in OpenGL documentation
(which uses column vectors and right-to-left concatenation),
post-multiplying by R means R*M,
and to apply the result to a vertex (column vector) v you would write R*M*v.

(Note however that OpenGL is strange in that it
 expects matrices in FORTRAN-style column-major order, so if you aren't careful
 you will end up giving it the transpose of the matrix you intended.
 This is extremely weird, so many OpenGL programmers (myself included)
 prefer to think and write OpenGL programs Performer-style (i.e. row vectors
 and left-to-right concatenation);
 the two reversals cancel each other out, everything works,
 and you get a more sane programming environment, in my humble opinion.)

Don

-- 
Don Hatch  hatch++at++sgi.com  (650) 933-5150  Silicon Graphics, Inc.

New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Fri Sep 17 1999 - 12:59:22 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.