Given a position vecotr,a oreintation matrix(3x3),so how can i calculate the view matrix!Could someone explain the process in more detail?Thank u~~~
Let R be the orientation matrix and T the translation vector. The view matrix V can then expressed as:
| R11 R12 R13 T1 |
| R21 R22 R23 T2 |
| R31 R32 R33 T3 |
| 0 0 0 1 |
Thank u,i want to know the process of computing this matrix!
If you are given R and T, there is nothing to compute, you only need to place the elements of R and T into result 4 by 4 matrix as thokra showed.
It is formed by multiplying the orientation matrix by the translation matrix ( http://en.wikipedia.org/wiki/Matrix_multiplication ):
[ 1 0 0 T1 ][ R11 R12 R13 0 ] [ R11 R12 R13 T1 ] [ 0 1 0 T2 ][ R21 R22 R23 0 ] = [ R21 R22 R23 T2 ] [ 0 0 1 T3 ][ R31 R32 R33 0 ] [ R31 R32 R33 T3 ] [ 0 0 0 1 ][ 0 0 0 1 ] [ 0 0 0 1 ]
If O is a 3x3 orthogonal matrix with the orientation of the camera (first column points to the right, middle column up, last column points negative view direction) and p is the position of the camera, then a point y in view space is transformed to world space as:
y = T(p) * R(O) * x,
where T§ returns a 4x4 translation matrix and R(O) returns a 4x4 rotation matrix (like in the other posts).
However, the view matrix should do the opposite. I.e., it should transform a world space point to view space:
x = inv(T(p) * R(O)) * y = R(O') * T(-p) * y,
where O’ is the transpose matrix and inv is matrix inversion.
So the view matrix is given by:
V = R(O') * T(-p).