My projects: SUGG (M), SYNONS, URLS, SIMILAR, Misc: 3Dengine, UniteHowTo, FliCC, TripIdeas, My blog.
Old/abandoned: TheRarestWords (TcCrnch).
Hi, I'm Slava V. and I develop those projects in free time.
To main page |

Right, Up, Back vectors From Modelview matrix

The modelview matrix actually contains 4 vectors:

In this text m[i] is i-th element of modelview matrix as returned by glGetFloat call.

The "Right vector" is ( m[0], m[4], m[8] ).
The "Up vector" is ( m[1], m[5], m[9] ).
The "Back vector" is ( m[2], m[6], m[10] ).

RUB is a mnemonic to easily remember order in which vectors are stored in modelview matrix.

Length of each of those vectors equals 1.0 always and the angle between any of them is 90 degrees - they are unit vector and the 3x3 matrix formed by R-U-B-vectors is called rotation matrix.

Camera center

The "encoded" camera center is m[12],m[13],m[14]. The "encoded" part is due to the fact that this is NOT world coordinates, but the coordinates in terms of "right-up-back vectors", (it's the position of world origin in this camera's coordinate frame), so to find the real position you have to do some calculations: -R*t, where R is [0 4 8; 1 5 9; 2 6 10] matrix and t is [12 13 14] column vector.

See Center of viewport's "3D coordinates of current camera center in PyOpenGL" section to find out how to "decode" it.

This article is a stub, it contains information that doesn't explain subject fully.