View Full Version : defining and manipulating 4x4 matrices

Lanfear

03-04-2004, 11:18 PM

I would like to multiply a matrix by some rotation and translation matrices. Can someone please give me an example of how to define a 4x4 matrix? DO we enter it row by row or column by column?

Can i vector multiply by (*)?

Many thanks!!

dorbie

03-05-2004, 01:41 PM

You can answer this question easily by loading an indentity matrix on the modelview, calling glRotate and reading the matrix result.

From the OpenGL FAQ:

http://www.opengl.org/resources/faq/technical/transformations.htm

[qoute]

9.005 Are OpenGL matrices column-major or row-major?

For programming purposes, OpenGL matrices are 16-value arrays with base vectors laid out contiguously in memory. The translation components occupy the 13th, 14th, and 15th elements of the 16-element matrix.

Column-major versus row-major is purely a notational convention. Note that post-multiplying with column-major matrices produces the same result as pre-multiplying with row-major matrices. The OpenGL Specification and the OpenGL Reference Manual both use column-major notation. You can use any notation, as long as it's clearly stated.

Sadly, the use of column-major format in the spec and blue book has resulted in endless confusion in the OpenGL programming community. Column-major notation suggests that matrices are not laid out in memory as a programmer would expect.

[/QUOTE]

dorbie

03-05-2004, 01:44 PM

P.S. you'll only be able to vector multiply if you have a class that has implemented a method to do su. There is no C or C++ code for matrix support in OpenGL, it's just a brainless array of floats.

OpenGl will perform appropriate vector multiplies during the transformation process but that is an automatic internal detail.

Lanfear

03-06-2004, 05:47 AM

I got it! All thanks to your help, dorbie. http://www.opengl.org/discussion_boards/ubb/smile.gif

Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.