# Thread: ModelView Matrix & Calc Translation factor

1. ## 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)

2. ## Re: ModelView Matrix & Calc Translation factor

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 2*cos45 |
| 0 sin45 cos45 2*sin45 |
| 0 0 0 1 |

3. ## Re: ModelView Matrix & Calc Translation factor

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?

4. ## Re: ModelView Matrix & Calc Translation factor

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

5. ## Re: ModelView Matrix & Calc Translation factor

Originally Posted by baconbeastnz
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, 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.

6. ## Re: ModelView Matrix & Calc Translation factor

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!

7. ## Re: ModelView Matrix & Calc Translation factor

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.....

8. ## Re: ModelView Matrix & Calc Translation factor

No this is

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

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

Here P is a column vector

9. ## Re: ModelView Matrix & Calc Translation factor

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

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•