[Bf-python] matrix multiplication problem

Gilbert, Joseph jgilbert at tigr.org
Tue Nov 25 18:08:57 CET 2003


Your right on the $money
Matrices are stored as a mat[16] in memory for performance. (I don't
know if this is true for all systems though.) OpenGL uses column-major
notation to do operations though. The difference really is pre- or post-
multiplication of the vector. 

If this is true is the py_matrix function correct when it says:

    self->rows[0] = newVectorObject ((float *)(self->mat[0]), 4);
    self->rows[1] = newVectorObject ((float *)(self->mat[1]), 4);
    self->rows[2] = newVectorObject ((float *)(self->mat[2]), 4);
    self->rows[3] = newVectorObject ((float *)(self->mat[3]), 4);

Doesn't mat[0] represent the first row of the matrix rather than the
first column? I guess it doesn't matter right? 

This is kinda of interesting:
http://research.microsoft.com/~hollasch/cgindex/math/matrix/column-vec.h
tml

The matrix faq is a big help.
Back to the salt mines.

-----Original Message-----
From: bf-python-admin at blender.org [mailto:bf-python-admin at blender.org]
On Behalf Of Willian Padovani Germano
Sent: Monday, November 24, 2003 11:52 PM
To: bf-python at blender.org
Subject: Re: [Bf-python] matrix multiplication problem

Hi Joe,

> This is the typical way blender uses matrix muliplication. However,
correct
> me if Im wrong but i think this is not correct.

Matrix order: 3d programming APIs like OpenGL and others don't store
matrix indices in the standard math order we learn, row-major.  OpenGL
uses column-major order (actually it stores m[4][4] as m[16], I guess).

BTW, the Matrix and Quaternion faq that now you can get here is a pretty
good resource (saw that they have two other faqs there, too, curve and
vector):

http://www.j3d.org/matrix_faq/

A search also came up with this:
http://oss.sgi.com/projects/ogl-sample/registry/ARB/transpose_matrix.txt

Another thing to consider when things don't look ok in 3d math is if
you're pre- or post-multiplying a matrix by a vector.

--
Willian, wgermano at ig.com.br

_______________________________________________
Bf-python mailing list
Bf-python at blender.org
http://www.blender.org/mailman/listinfo/bf-python



More information about the Bf-python mailing list