Advertisement

3x3/3x2 orthographic projection matrix

Started by September 15, 2016 02:27 PM
1 comment, last by JohnnyCode 8 years, 4 months ago

Hey Volks

I have some trouble getting my 3x3 / 3x2 orthographic Matrix running from my 4x4 Matrix that looks like


2.0f * invRL           , 0                      , 0                      , 0
0                      , 2.0f * invTB           , 0                      , 0
0                      , 0                      , -2.0f * invFN          , 0
-(right + left) * invRL, -(top + bottom) * invTB, -(zFar + zNear) * invFN, 1

where


invRL = 1.0f / (right - left)
invTB = 1.0f / (top - bottom)
invFN = 1.0f / (zFar - zNear)

But I cant currently figure out (maybe related to the weather) how to make a 3x3 (and 3x2) Matrix from it looking same as the 4x4 one.

Thanks in advance

Are you asking how to create a 3x3/3x2 matrix from an existing 4x4 matrix(or 4x4 orthographic matrix)?

If you are you normally make an orthographic or perspective matrix as a 4x4 Matrix. But if you really want to make a 3x3 matrix from a 4x4 matrix it isn't that difficult as you are just going to copy over the values of the of the X,Y, Z and ignore the W component values. However, if you want to convert a 4x4 orthographic matrix to a 3x3 matrix you're going to lose some data, in this case '-(right + left) * invRL, -(top + bottom) * invTB, -(zFar + zNear) * invFN'.

I hope that answers your question?

Advertisement

how to make a 3x3 (and 3x2) Matrix from it looking same as the 4x4 one.

You can't.

How exactly is 3x3 matrix gonna transform 3d vectors, if it cannot add translation component to them by putting 1 into a 4d vector?

The translation component is :

-(right + left) * invRL, -(top + bottom) * invTB, -(zFar + zNear) * invFN, 1

and only 4d vectors with 1 as fourth component can have this base vector added, capish?

Now what you might be after though, is 4x2 matrix I gess?

With such a matrix you can transform 4d vectors into 2d vectors what I think is what you wish (the projected 2d, screen, etc)

Such a matrix should be simply the first 2 columns of your matrix in post as you layouted it.

This topic is closed to new replies.

Advertisement