• Create Account

## row major vs column major and multiply direction

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

3 replies to this topic

### #1greenzone  Members

676
Like
0Likes
Like

Posted 18 May 2013 - 12:42 PM

When I am using matrices in my opengl program I have been doing multiples left to right.

so say M is my original matrix. if i want to apply a rotation to M i would multiple the rotation matrix R to M in this fation

Mrotated =M*R

does it mater whether I am using a row major system vs column major system when it come to the direction of my multiply? meaning

this, applying a rotation to M:      M*R

versus

this, applying a rotation to M:      R*M

or are these two separate issues?

J-GREEN

Greenpanoply

### #2Zaoshi Kaba  Members

7785
Like
2Likes
Like

Posted 18 May 2013 - 01:13 PM

It does matter. If you transpose row major matrix you get column major matrix and multiplication order becomes reversed.

### #3Glass_Knife  Moderators

8600
Like
5Likes
Like

Posted 18 May 2013 - 03:44 PM

POPULAR

http://www.scratchapixel.com/lessons/3d-basic-lessons/lesson-4-geometry/conventions-again-row-major-vs-column-major-vector/

The above article will explain it better than I can!

Enjoy.

I think, therefore I am. I think? - "George Carlin"
My Website: Indie Game Programming

My Book: http://amzn.com/1305076532

### #4Hodgman  Moderators

49387
Like
6Likes
Like

Posted 19 May 2013 - 11:53 PM

POPULAR

Row major storage vs column major storage makes absolutely no difference on your maths. The meaning A*B is strictly defined according to mathematical rules. The way that matrices are stored in memory is just an invisible implementation detail.

What does matter though is whether you treat your vectors (vec4, float4, etc) as row-vectors or column-vectors, i.e. is a vec4 a mat1x4 or a mat4x1?

If you write vec * mat, that's the same as mat1x4 * mat4x4.

If you write mat * vec, that's the same as mat4x4 * mat4x1.

These have different mathematical meanings.

Depending on which one of these conventions you use (which is an entirely different issue from column/row-major storage), you will store your values differently inside your matrices.

Edited by Hodgman, 19 May 2013 - 11:54 PM.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.