**0**

# Can someone explain projection matrices?

###
#1
Crossbones+ - Reputation: **4341**

Posted 10 September 2011 - 06:44 AM

1) I put in a position and a projection matrix

2) Complex math

3) I get position as scaled right and x and y divided by its z???

What i dont get is where the x and y are divided by z. Is it even done in the projection matrix?

Explain please O_e

o3o

###
#2
Crossbones+ - Reputation: **24112**

Posted 10 September 2011 - 07:11 AM

So I will explain in the most simplistic and imagery-based way possible.

When you look at your city, buildings farther away look smaller. As it turns out, any building the same size as another, but twice as far away, will be half the size.

Since Z is the distance away from you, the size of the building is a function of Z.

That is, if the Z value is doubled, the building is twice as far away from you. So to make it twice as small you need to divide by Z.

A projection matrix is designed specifically to facilitate this type of translation.

L. Spiro

My Art: http://l-spiro.deviantart.com/gallery/4844241/Realism My Music: https://soundcloud.com/l-spiro

L. Spiro Engine: http://lspiroengine.com

L. Spiro Engine Forums: http://lspiroengine.com/forums

###
#3
Members - Reputation: **768**

Posted 10 September 2011 - 07:17 AM

Example:

v1 element of R3

v2 element of R4

v1 = v2 / v2.w

v2 = c * v1

So they simply use the w-component to be able to use the division x/z and y/z.

The division of x/z and y/z can be figured out by using the intercept theorem.

###
#5
Moderators - Reputation: **9972**

Posted 10 September 2011 - 07:21 AM

###
#6
Members - Reputation: **1315**

Posted 10 September 2011 - 07:25 AM

Matrix multiplication is just a mathematical mechanism like normal addition or multiplication or division. You just have to learn how to perform it.

Linear Algebra tutorial. I don't know if this tutorial is any good but it was the first hit on google:

http://blog.wolfire....elopers-part-1/

Matrix Multiplication

http://en.wikipedia...._multiplication

Projection Matrix construction

http://www.songho.ca...tionmatrix.html

-me

###
#7
Crossbones+ - Reputation: **4341**

Posted 10 September 2011 - 07:41 AM

So what were doing is multiplying a 4 component vector by a 4x4 matrix and then dividing the x y and z of the vector by w?

How does the z of the vector get to the w of it? When multiplying the matrix and vector its all like w and parts of the matrix.

Is the z put to w manually, or is the z somehow moved into the matrix in some point or what?

o3o

###
#8
Moderators - Reputation: **9972**

Posted 10 September 2011 - 07:57 AM

[0, 0, -1, 0] * [x, y, z, w]

^{T}= 0*x + 0*y - 1*z + 0*w = -z

So, just by multiplying a column vector by that matrix, you can see that the W-component of the resulting vector is the negative Z-component of the input vector. It's standard matrix multiplication.