PDA

View Full Version : Matrix Problems...



05-25-2001, 10:44 AM
Well i would like to code a matrix class and i remembered the MEGA-BIG fight (i don't remember how many posts) between Michael Steinberg and Elric about Row Major Matrix but i don't manage to find it!
So i ask: my class use a float m[16] tab but what are the differences in the code between row major operations and column major operations (for example in multiplication, or dumping to the screen, ...).
Thanks by advance.

TheDD

ffish
05-25-2001, 10:39 PM
It's like this:



GLfloat m[16];
...
// Row major output (the mathematicians' traditional way).
using namespace std;
cout << m[0] << "\t" << m[1] << "\t" << m[2] << "\t" << m[3] << endl <<
m[4] << "\t" << m[5] << "\t" << m[6] << "\t" << m[7] << endl <<
m[8] << "\t" << m[9] << "\t" << m[10] << "\t" << m[11] << endl <<
m[12] << "\t" << m[13] << "\t" << m[14] << "\t" << m[15] << endl;

// Column major output (the OpenGL way).
cout << m[0] << "\t" << m[4] << "\t" << m[8] << "\t" << m[12] << endl <<
m[1] << "\t" << m[5] << "\t" << m[9] << "\t" << m[13] << endl <<
m[2] << "\t" << m[6] << "\t" << m[10] << "\t" << m[14] << endl <<
m[3] << "\t" << m[7] << "\t" << m[11] << "\t" << m[15] << endl;


Hope that helps.

05-26-2001, 07:05 AM
Yes, thanks a lot for your help, but now i only know how to dump my matrix to the screen! Is there any differences in the code in matrix multiplication, addition or any others operations?

If somebody remember in which post (i accept urls ;-) ) there was the "discussion" about the way that OpenGL treat matrix between Michael and Elric (and some others...), please tell me.

One more question, my objectif is to code a matrix class which can replace the OpenGL matix (for a software 3D Engine for example) and i was asking me if the sources code of the function gluLookAt was available?!

Thanks.
TheDD

05-26-2001, 11:18 AM
http://www.opengl.org/discussion_boards/ubb/Forum2/HTML/002537.html

Thanks guys ;-)
TheDD

RandyU
05-26-2001, 11:37 AM
There are no difference in operations - it only influences output.