Sign in to follow this  
mike74

bottom row of 4x4 matrix

Recommended Posts

Could someone please tell me when the bottom row of a 4x4 matrix will not equal: 0 0 0 1 I know there must be instances when this is the case or you wouldn't have to normalize x, y, and z by dividing by w. However, I thought scaling and rotation only affect the first 3x3, and translation only affects the top 3 in the last column. Mike C. http://www.coolgroups.com/zoomer/

Share this post


Link to post
Share on other sites
In all isometric tranformations it will be 0001. Same with scaling each coordinate. Generally: in all linear 3D transformations + offsets.

When you do need to perform some other operations apart from multiplying and adding, as matrix/vector operations only do that, you do need to accumulate some info in w vector coordinate, to explicilty do something with it later (divide xyz/w, for example).

This is used in non-orthographic projections, for example.
Check out how it looks, in gl reference documentaiton.
/def

Share this post


Link to post
Share on other sites
What do you mean by isometric transformations?

I'm using OpenGL for a skeletal animation system, and I'm just doing scaling, rotation, and translation. The w coord is not equal to 1.

I did have a call to gluPerspective. Could that change it?

Right now, I'm getting the absolute value of a point like so:

GLfloat matrix[16];
glGetFloatv(GL_MODELVIEW_MATRIX, matrix);
newpoint.x = matrix[12]/matrix[15];
newpoint.y = matrix[13]/matrix[15];
newpoint.z = matrix[14]/matrix[15];

If I take out the /matrix[15], it doesn't work right.

Mike C.
http://www.coolgroups.com/zoomer/

Quote:
Original post by deffer
In all isometric tranformations it will be 0001. Same with scaling each coordinate. Generally: in all linear 3D transformations + offsets.

When you do need to perform some other operations apart from multiplying and adding, as matrix/vector operations only do that, you do need to accumulate some info in w vector coordinate, to explicilty do something with it later (divide xyz/w, for example).

This is used in non-orthographic projections, for example.
Check out how it looks, in gl reference documentaiton.
/def


Share this post


Link to post
Share on other sites
Quote:
Original post by mike74
What do you mean by isometric transformations?

By definition - transformations saving distances between points.
dist(p,q) == dist(f(p),f(q))
So translations and rotations are ok.

Quote:
I'm using OpenGL for a skeletal animation system, and I'm just doing scaling, rotation, and translation.

And that should suffice, skeletal animation consists only of linear transformations.

Quote:
The w coord is not equal to 1.

'w' coord of... what? vector after transformations? Matrix column?

Quote:
I did have a call to gluPerspective. Could that change it?

You should not normally use perspective transformations for anything other than rendering. IOW don't touch the result on GL_PROJECTION matrix stack.
If you called gluPerspective while having GL_MODELVIEW active, it will most likely cause a disaster. In other cases, you should not be directly concerned about 'w' coordinate at all.

Quote:

Right now, I'm getting the absolute value of a point like so:

GLfloat matrix[16];
glGetFloatv(GL_MODELVIEW_MATRIX, matrix);
newpoint.x = matrix[12]/matrix[15];
newpoint.y = matrix[13]/matrix[15];
newpoint.z = matrix[14]/matrix[15];

If I take out the /matrix[15], it doesn't work right.


So what is this all for afterall?

Share this post


Link to post
Share on other sites
By w coordinate, I mean the fourth element of the point vector, which is usually 1. So, does scaling affect the bottom row of the 4x4 matrix? Scaling does not seem to be an isometric transform but you implied it didn't affect the bottom row.

Mike C.
http://www.coolgroups.com/zoomer/

Share this post


Link to post
Share on other sites
Scaling is a linear transform. All linear transformations in 3D can be expressed using only 3x3 matrices. The rest part is obsolete then, thus is set to identity values.
Translation is not linear, but it's isometric, so doesn't affect the bottom row either.

Share this post


Link to post
Share on other sites
Well, does a concatenation of scaling, translation, and rotation affect the bottom row? I still don't see when it's affected.

Mike C.
http://www.coolgroups.com/zoomer/

Share this post


Link to post
Share on other sites
Take two matrices with botom row 0001 and multiply them. See what happens.

Quote:
original post by mike74
I still don't see when it's affected.

Why don't you simply debug your program? Usually all becomes clear then...

Share this post


Link to post
Share on other sites
Here's my matrix before calling gluPerspective(90.0f,1 ,0.1f,100.0f):

1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1

Here is it afterwards:

1 0 0 0
0 1 0 0
0 0 -1.002002 -0.200200
0 0 -1 0

Should gluPerspective be doing this weirdness to my matrix?

Mike C.
http://www.coolgroups.com/zoomer

Share this post


Link to post
Share on other sites
By isometric transforms deffer means that your matrix should be normalized as well as having the 3 axes orthogonal to each other.

Calling gluPerspective would not make your homogeneous(w) coord negative. Why it does that to you, I have no idea.
gluPerspective does this (I think ;*))

1. Subtract view from pos to get the inverse forward vec
2. Cross Up and forward to get the right vector
3. Normalize all the vectors
4. Fill the transpose of the object matrix, thereby making a camera matrix
5. Translate with negative translation

So basically deffer is right in saying that the matrix should be isotropic and would not affect your bottom row.

Share this post


Link to post
Share on other sites
What number are you referring to as the homogeneous(w) coord?

Mike C.
http://www.coolgroups.com/zoomer/

Quote:
Original post by relsoft
By isometric transforms deffer means that your matrix should be normalized as well as having the 3 axes orthogonal to each other.

Calling gluPerspective would not make your homogeneous(w) coord negative. Why it does that to you, I have no idea.
gluPerspective does this (I think ;*))

1. Subtract view from pos to get the inverse forward vec
2. Cross Up and forward to get the right vector
3. Normalize all the vectors
4. Fill the transpose of the object matrix, thereby making a camera matrix
5. Translate with negative translation

So basically deffer is right in saying that the matrix should be isotropic and would not affect your bottom row.


Share this post


Link to post
Share on other sites
You implied gluPerspective was making it negative. It's actually making it 0.

Mike C.
http://www.coolgroups.com/zoomer/

Quote:
Original post by relsoft
The (1)

Last element.


Share this post


Link to post
Share on other sites
I don't have access to Google thanks to TMobile.

Anyway, here's the manual for gluPerspective:

NAME
gluPerspective - set up a perspective projection matrix


C SPECIFICATION
void gluPerspective( GLdouble fovy,
GLdouble aspect,
GLdouble zNear,
GLdouble zFar )

delim $$

PARAMETERS
fovy Specifies the field of view angle, in degrees, in
the y direction.

aspect Specifies the aspect ratio that determines the field
of view in the x direction. The aspect ratio is the
ratio of x (width) to y (height).

zNear Specifies the distance from the viewer to the near
clipping plane (always positive).

zFar Specifies the distance from the viewer to the far
clipping plane (always positive).


DESCRIPTION
gluPerspective specifies a viewing frustum into the world
coordinate system. In general, the aspect ratio in gluPer-
spective should match the aspect ratio of the associated
viewport. For example, $ "aspect" = 2.0 $ means the
viewer's angle of view is twice as wide in x as it is in y.
If the viewport is twice as wide as it is tall, it displays
the image without distortion.

The matrix generated by gluPerspective is multipled by the
current matrix, just as if glMultMatrix were called with the
generated matrix. To load the perspective matrix onto the
current matrix stack instead, precede the call to gluPer-
spective with a call to glLoadIdentity.

Is there something in there you wanted me to see?

Mike C.
http://www.coolgroups.com/zoomer

Quote:
Original post by deffer
gluPerspective


Share this post


Link to post
Share on other sites
Quote:
Original post by mike74
1 0 0 0
0 1 0 0
0 0 -1.002002 -0.200200
0 0 -1 0

Should gluPerspective be doing this weirdness to my matrix?


(slightly modified) from http://pyopengl.sourceforge.net/documentation/manual/gluPerspective.3G.html (second link here)

zf -> zFar
zn -> zNear
as -> aspect

(f/as) 0 0 0
0 f 0 0
0 0 (zf+zn)/(zn-zf) (2*zf*zn)/(zn-zf)
0 0 -1 0


Share this post


Link to post
Share on other sites
Quote:
Original post by relsoft
By isometric transforms deffer means that your matrix should be normalized as well as having the 3 axes orthogonal to each other.

Calling gluPerspective would not make your homogeneous(w) coord negative. Why it does that to you, I have no idea.
gluPerspective does this (I think ;*))

1. Subtract view from pos to get the inverse forward vec
2. Cross Up and forward to get the right vector
3. Normalize all the vectors
4. Fill the transpose of the object matrix, thereby making a camera matrix
5. Translate with negative translation

So basically deffer is right in saying that the matrix should be isotropic and would not affect your bottom row.



What was I thinking?!! This is gluLookAt.

major booboo. Sorry guys. :*)

Share this post


Link to post
Share on other sites
Quote:
Original post by mike74
Could someone please tell me when the bottom row of a 4x4 matrix will not equal:

0 0 0 1

I may be mistaken but doesn’t OpenGL use the right most column for that?

[Edited by - Grain on July 13, 2005 4:10:38 AM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this