3x3 perspective projection matrix

Hello All!

I was wondering if it is possible to construct a 3x3 perspective projection matrix? I searched for this, but could not find much help. I was able to find lots of information on 4x4 matrices. But, i just wanted to know if i somehow can do it using a 3x3 matrix. Also, i do not really want to preserve the Z values. So, it doesn’t matter to me if A(x, y, z) and B(x1, y1, z1) are projected to the same value W(xWin, yWin).

Is it possible to do something like this?
Thanks in advance!

http://www.opengl.org/sdk/docs/man/xhtml/glFrustum.xml

All 4 rows and all 4 columns are used in a perspective projection.

You could construct a perspective projection on-the-fly in a shader (using the info on the glFrustum man page to calculate it), and only the 6 params to glFrustum would be needed to do so, but I’m having a hard time seeing any kind of use case where you’d actually want to do this.

Hi mhagain,

I’m just curious to know if this is mathematically possible to use a 3x3 matrix. Also, in OpenGL, isn’t the projection matrix generated invertible? I am not looking for an invertible matrix.

Thanks for the response :slight_smile:

No, it is not. The perspective projection matrix generates 4D homogeneous coordinates. You cannot use a 3x3 matrix and generate a 4D vector from it.

> No, it is not. The perspective projection matrix generates 4D homogeneous coordinates. You cannot use a 3x3 matrix and generate a 4D vector from it.

Hi Alfonse Reinheart,
Thanks for the reply. Well, i didn’t want to obtain a 4D vector. I wanted to obtain a 2D vector. Just the window coordinates. Quoting myself:

But, i just wanted to know if i somehow can do it using a 3x3 matrix. Also, i do not really want to preserve the Z values. So, it doesn’t matter to me if A(x, y, z) and B(x1, y1, z1) are projected to the same value W(xWin, yWin).

Thanks!

To the GPU a 2D vector (“just the window coordinates”) is still a 4D vector - it’s padded with [0,1] at the end; similarly 3D is padded with [1] at the end.

I’m not entirely certain why you feel you need to do this with a 3x3 matrix (which you can’t anyway) - you may have some idea that you’re going to “save memory” or “have less calculations” by doing so, but let me tell you right now - you’re not. Your GPU will still use 4x4 internally anyway, so you may as well work with your GPU rather than against it.

Well, i didn’t want to obtain a 4D vector. I wanted to obtain a 2D vector. Just the window coordinates.

You can’t get to window coordinates without first passing through clip-space and normalized-device coordinates. Clip-space is 4D homogeneous, and NDC-space is 3D (the result of dividing the clip-space vector by its W component). You can’t just pretend that these steps don’t happen. And since perspective projection is a non-linear transform, it cannot be accomplished by a linear operation like a matrix multiply.

Hi mhagain, Alfonse Reinheart,

Thanks for the replies. I think now its clear to me. We thus have two phases in the perspective projection:

  1. Perspective transformation -> gets us to the clip space. and this is a linear operation.
  2. Perspective divide -> this is the non-linear operation.

So, its not possible with a 3x3 matrix
Am i correct about this?

EDIT: in fact i had seen somewhere the use of a 3x3 matrix for perspective scaling/shearing. I assumed this is the same as perspective projection. Could you please tell me what exactly perspective scaling/shearing is?

Shearing and scaling can be done with a 3x3 matrix. Also rotations, but not perspective scaling. The following matrix

a 0 0
0 b 0
0 0 c

will scale ‘x’ with a, ‘y’ with b and ‘z’ with c. Shearing is where, in the transformation process, one of the dimensions are added to one of the other (with a scale factor). See http://en.wikipedia.org/wiki/Shear_mapping for example.

Translation is a special case of this. The constant ‘1’ in position 3,3 is added to ‘x’, ‘y’ or ‘z’ (scaled with a constant).

Should be added that you can easily take a 3x3 matrix and convert it to 4x4 - in the case above it’s:

a 0 0 0
0 b 0 0
0 0 c 0
0 0 0 1

I.e. just pad each row and column with zeroes, with the exception of the very last entry, which is 1.

Thanks for the replies Kopelrativ, mhagain.

@Kopelrativ:
> Shearing and scaling can be done with a 3x3 matrix. Also rotations, but not perspective scaling.

So, is perspective scaling same as perspective projection? I tried searching on google, but not much information is available on this topic.

PS: Kindly excuse me if this is too trivial a question to be asking. I would like to read more in depth about this. All books/links i refered just give a matrix that does the perspective projection. But i wanted to know how exactly this is derived and if there are other ways to do it. So, this is not for optimization or anything of that sort. Its just for learning more in detail about perspective projections in general.

Thanks!

So, is perspective scaling same as perspective projection?

He didn’t say “perspective scaling”; he said scaling.

I would like to read more in depth about this. All books/links i refered just give a matrix that does the perspective projection.

cough

> cough

haha! thanks :smiley: