# ModelView Matrix & Calc Translation factor

My modelview matrix is currently:

1 0 0 0
0 cos45 -sin45 0
0 sin45 cos45 0
0 0 0 0

Now I call glTranslate(0,2,0) and multiply the above matrix with the below one.

1000
0101
0010
0001

I can figure out the first 3x3 block which is just

1 0 0
0 cos45 -sin45 0
0 sin45 cos45 0

But how do I figure out the right most column ( the translation values)

This is just a 4x4 matrix multiply. Multiply rows of matrix 1 by column of matrix 2. So

|1 0 0 0 |
|0 cos45 -sin45 0 |
|0 sin45 cos45 0 |
|0 0 0 1 |
*
|1 0 0 0|
|0 1 0 2|
|0 0 1 0|
|0 0 0 1|

=
| 1 0 0 0 |
| 0 cos45 -sin45 2cos45 |
| 0 sin45 cos45 2
sin45 |
| 0 0 0 1 |

Ah thankyou for the reply. have looked at the diagram and I understand it now. I did look at it before and misinterpreted it .

Thankyou! I also have another question which I will post here.

When we calculate the position of each vertex we multiply it by the modelview matrix right, so how is the new position calculated?

Do we just represent the point P (4,3,2) as a 3x1 matrix then do matrix multiplication between the point and the MV matrix?

Yes, you can represent a point P (4,3,2,1) (x,y,z,w) as a 4x1 matrix. This is called homogeneous coordinates.

In OpenGL, the modelview matrix and a vertex is multiplied in this order P’ = MV * P

Yes, as the other poster already said.

Of course, usually we don’t apply our matrix transformations to vertexes directly. The video driver applies our model view and projection matrixes to our vertexes when we render them. Modern accelerated video hardware is a WHOLE lot faster for matrix math like this than the CPU.

ok cool, thanks, so glad i finally understands how that all works now =D for my next assignment I need to make ray caster should be fun but still need to understand quite a few more concepts lol.

cheers guys!

Actually, having just tried to 4x1 multiplication, I have run into another misunderstanding.

Let p = Mv x P

MV = below

1 0 0 0
0 1 0 0
0 0 -1 4
0 0 0 1

Now to calc P I get:

X = 1xX + 0xX + 0xX + 0xX
Y = 0xY + 1xY + 0xY + 0xY
Z = 0xZ + 0xZ - Z + 4Z

However the answer for z is supposed to be : “-z +4”

(O_o)/") hmph…

No this is

Suppose we have a point P(X,Y,Z,W=1)

X = 1X + 0Y + 0Z + 0W = X
Y = 0X + 1Y + 0Z + 0xW = Y
Z = 0
X + 0Y + -1Z + 4W = -Z + 4 => W = 1
W = 0
X + 0Y + 0Z + 1*W = 1

Here P is a column vector

AHHHH!! I seee I see! another hurdle leaped Thanks = )