# how to get Camera infomation from Matrix of Modelmatrix

i dont know the relationship between Matrix and eyeposition,centerposition,upposition of Camera. would would tell me ?

thanks
hshutao

## Comment viewing options

### Re: how to get Camera infomation from Matrix of Modelmatrix

I found these tutorial programs clarifying when learning OpenGL:

http://www.xmission.com/~nate/tutors.html

Good luck!

### Re: how to get Camera infomation from Matrix of Modelmatrix

Hello,

the Matrix can represent nearly any transformation you can think of. It is generally difficult to "extract" the information from the Matrix.

But let assume that we have a Matrix, that reprezent _only_ a camera, so it is
1) translated to the "eye-position"
2) looks in the direction "look-at"
3) the direction up is "up-dir"

That matrix will have a shape of
A1 B1 C1 X
A2 B2 C2 Y
A3 B3 C3 Z
00 00 00 1

The point (-X,-Y,-Z) is the "eye-position".

The 3x3 matrix (let's call it M)
A1 B1 C1
A2 B2 C2
A3 B3 C3
represent only rotation in our case [this is only true because we presumed the matrix corresponds to a camera. Generally this matrix can also reprezent some scaling.]

Now we compute the _inverse_ of this 3x3 matrix, lets call it 1/M. As any matrix, this matrix can be "multiplied" by a point to get a transformed point. The "look-dir" is then (1/M)*(0,0,1) and the "up-dir" is (1/M)*(0,1,0).
This mean that when (1/M) is
a1 b1 c1
a2 b2 c2
a3 b3 c3
then "look-dir" is (c1,c2,c3) and "up-dir" is (b1,b2,b3). [(a1,a2,a3) is "right-dir"].

If you want to know why, you can read a wiki article on transformation matrices and rotation matrices.