# [ODE] ODE internals: row-major or column-major?

Mauro G. Todeschini mauro2006todeschini at itia.cnr.it
Fri Oct 6 06:23:48 MST 2006

```Jon Watte (ODE) wrote:
> There's also the question of row vectors vs column vectors.
>
> See http://www.mindcontrol.org/~hplus/graphics/matrix-layout.html
Yes, I read that document before asking my question, but It didn't solve
my doubts.
I understand that you can use row vectors and post-multiply or column
vectors and pre-multiply.
To me It seems that ode pre-multiplies (reading the code from
dMULTIPLTOP_333 for example) so It should use column vectors on the right:
A, B, are rotation matrixes and p is a point. B happens (in time) before A.
p'=ABp is what ode does to obtain the transformed p' point.
I think that the matrix at the link I posted
http://planning.cs.uiuc.edu/node102.html
uses the same convention, so If ode is row-maior and pre-multiplies and
uses a column vector on the right I still cannot understand why It
doesn't store the matrix that way dRFromEulerAngles.
Ok, I know that It works, and that probably I miss something stupid
but... I have to understand :D
I think I need some hints from you experts :D

Bye and Thanks

>
> Cheers,
>
>              / h+
>
>
> Mauro G. Todeschini wrote:
>> Hi,
>> 	I'm looking at ode code and I have some question that I haven't been
>> able to solve googling. So I need your help :)
>> I've read that ode stores matrixes in memory in row-major style (which
>> is opposite to OpenGL column major style). I've also read that row-major
>> means that if I have a (rotation) matrix like this (3 rows, 4 columns):
>> [m11 m12 m13 m14]
>> [m21 m22 m23 m24]
>> [m31 m32 m33 m34]
>> ... It get stored in an array like this:
>> [a0]=m11 -
>> [a1]=m12 First row
>> [a2]=m13
>> [a3]=m14 -
>> [a4]=m21 -
>> [a5]=m22 Second Row
>> [a6]=m23
>> [a7]=m24 -
>> [a8]=m31  -
>> [a9]=m32  Third Row
>> [a10]=m33
>> [a11]=m34 -
>> Ok, It seemed clear but... =:-o
>> I looked at the code of the function dRFromEulerAngles (file
>> rotation.cpp) and to me It seems that the rotation matrix get stored in
>> column-major style.
>> The rotation matrix of the composition of a X rotation followed by a Y
>> rotation followed by a Z rotation in fact shold have the form shown at
>> http://planning.cs.uiuc.edu/node102.html
>> Anybody can clarify? Is ODE row or column major?
>> There is something I really cannot catch...
>>
>> Thanks and Bye
>>
>> _______________________________________________
>> ODE mailing list
>> ODE at q12.org
>> http://q12.org/mailman/listinfo/ode
>>
>>
>>
> _______________________________________________
> ODE mailing list
> ODE at q12.org
> http://q12.org/mailman/listinfo/ode
>

```