# OpenGL OpenGL Model View Matrix Intuition

This topic is 2841 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

[color="#333333"]Would, you mind answering a question? ...

Question( It has been eating away at my brain for DAAYYYS!)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I get how both equations relate to each other somewhat...
I just don't understand where the zeros come from iin the end of the model-view matrix

This guy attempts to derive the model view matrix...and i somewhat get it, but LOOK, UP, and RIGHT vectors have three components...(http://knol.google.c...transformation#)
However they all have a fourth one that is a zero...That gets me confused...

Is it added because point/vector Eye has four components(x,y,z,w)...and and the other ones only have three?
Do all the other vectors just get an extra zero to fit with the vector/point Eye?
Is that allowed?
Or is it just the identity matrix filled in with the specified data?
Is that allowed?
What is really going on in there? I am so confused...

SO, the overall question is how exactly, how did the first equation go into matrix form? Could it please be given in a step by step process...LOOK, UP, and RIGHT vectors all have three components but EYE vector has four(x,y,z,w)...Oh and what are the three zeros for at the end? I am soooo confused, well not 'sooo' confused! Just a little, but its frustrating!

##### Share on other sites
Appendix F in the Red Book shows how the transformation matrices, especially the rotation and translation ones, look like. Just keep in mind that there is a difference in column versus row vector notation between the Red Book and your equations, so just transpose one of them and compare. The zeros in the left column, or bottom row, is just because of how the transformation matrices look like. OpenGL uses 3-dimensional homogeneous coordinates, hence why the vectors and matrices are 4-dimensional.

##### Share on other sites

Appendix F in the Red Book shows how the transformation matrices, especially the rotation and translation ones, look like. Just keep in mind that there is a difference in column versus row vector notation between the Red Book and your equations, so just transpose one of them and compare. The zeros in the left column, or bottom row, is just because of how the transformation matrices look like. OpenGL uses 3-dimensional homogeneous coordinates, hence why the vectors and matrices are 4-dimensional.

[color=#333333]So [x] = x*[rightx] + y*[upx] + z[lookx] + [Eye.x]
[y] x*[righty] y*[upy] z[looky] [Eye.y]
[z] x*[rightz] y*[upz] z[lookz] [Eye.z]
[w] [Eye.w]
Is that written correctly?
You might not be able to see it, but i am basically taking the right coordinate and multiplying it by the correct vector.(The site took way my spaces )

LOOK, RIGHT, and UP vectors are only for translation, they create the coordinate grid that the coordinate will be multiplied by. I get that much. I don't quite understand homogeneous coordinates, but i no that they are there in the Eye coordinate and the main coordinate...all coordinates.

However, i don't get how to do the mathematics to get the new matrix...
Could you plz show me how to get the equation into matrix?

I now no the intuition, but how does some one, such as myself go about actually creating that matrix from the first equation, if that were the only thing that we knew, and we did not no how the final matrix would look. How would someone go about to get the same outcome in matrix form, transposed or not?

##### Share on other sites
Your equation is correct, and is the result from both the vector and the matrix equations you first posted. I don't understand what your questions are though, so I'm not sure I'm really answering anything you're asking.

##### Share on other sites
Let me be clearer, sorry 4 dat.
I just wanted to know how to get the equation one into equation 2...however I think I have gotten it!

[color="#333333"]I decided to think of it as a system of equations
[font="monospace"][color="#333333"][/font]
[color="#333333"]So, what is happening to every coordinate, is that they are being multiplied by their part of every vector and then shifted over by their specific part of Eye.

[color="#333333"]then i can turn that system of equations into a matrix like:
[color="#666666"][size=2][color="#333333"]by pulling out all the variables in one equations in a vector and lining up the rest in a matrix form...

[color="#333333"]So the isolated matrix is the Modelview Matrix!
[color="#333333"]and the last row must always stay [0001], right

[color="#333333"]Thus the Modelview Matrix has three vectors and a location in space. This could all be represented or inscribed into a matrix. The components of the coordinate vector are then multiplied and altered by the Modelview Matrix. Coordinate vectors are always altered by the Modelview matrix: it could be the identity or a custom made one. Each component of the coordinate vector has its own equation, which will take into account the position and orientation of the coordinate in 'world space'.

[color="#333333"]Is this all correct? And is there anything I am missing?

##### Share on other sites
In general you are mostly correct. However, the last row doesn't have to be [0,0,0,1], it just happens to become that given a rotation and a translation matrix. For example, look into a projection matrix, and you'll see that the last row is something else. From a 3-dimensional point of view, you can look at the given matrices as an orientation and a position, but in 3-dimensional homogeneous space, you need to think with the fourth dimension as well. If you don't know what that is, there's no need to bother about it anyway in practice.

##### Share on other sites

In general you are mostly correct. However, the last row doesn't have to be [0,0,0,1]

I was talking about the Modelview Matrix, the last row in the Modeview Matrix must be [0,0,0,1], right!
I know the projection matrix is different, but at the moment i don't wanna think about that.

I just want to go one matrix multiplication at a time!

##### Share on other sites
As I said, there's not "must" when it comes to what the last row looks like. It usually is, but there's not requirement that the last row of the modelview matrix has to be [0,0,0,1], it's just a result of what different transformation matrices happen to look like. Even though you don't care about it in this particular post, put a perspective projection into the modelview matrix, and you have a different last row; it just shows that the modelview matrix doesn't have to have a specific last row, just that you happen to get one here.

##### Share on other sites
Thanks for keeping up with me ...i no i can be a bit stubborn , but you saying that the last row does not need to be [0001] is disturbing me...however now i think i get what you mean!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
So, three 3x3 matricies for rotation, and one 4*1 matrix for translation.
I am representing the transformation and rotation matrices together in one matrix and I get [000 Eye.w] for the last row , amusing w is a constant...

Eye.w is typically 1, but can be changed to another value. So typically the last row would look like [0001] , but in all cases it must look like[000 wconstant] in the Modelview Matrix that is?

If this is not the case, what else could the last row look like besides [000 wconstant]?
Are you saying that the wconstant could be placed anywhere in the last row?

##### Share on other sites
The last row of the standard perspective projection matrix in OpenGL is [0, 0, -1, 0] for example. And that's just the projection itself; additional transformation can even bring other non-zeros into the last row, especially the last element which is commonly non-zero alone.

I'm definitely not saying that you can place it anywhere, I don't know where you go that from. Just like any other part of a matrix it has a specific function, just not a commonly used one in practice. You can't just place the constant anywhere. The reason, for example, you have a non-zero element in the second-last element (like the -1 in the projection matrix) is to project the Z-component of the vertex onto the W-axis. When performing the perspective division (where divide all components of the vector by its W-component) to transform from 3-dimensional homogeneous space to 3-dimensional space, you are effectively dividing by the Z-component. Thus, you scale the coordinates based on their Z, and they appear smaller by increased Z-distance. That's what perspective is about; objects become smaller when they are viewed from further away.

But that is, as I said, not really what your matrices in your first post was about. Just an answer to why the last row isn't always [0, 0, 0, 1].

1. 1
2. 2
Rutin
15
3. 3
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633725
• Total Posts
3013559
×