Archived

This topic is now archived and is closed to further replies.

Seaman

xyzw

Recommended Posts

In one of my curious moods today, just what is the effect of the w coordinate? I can undertstand 3 dimensions, but getting my head round what it actually does is confusing me a little(easily done). oh well if any one can tell me something I''ll be greatful and prolly more confused.

Share this post


Link to post
Share on other sites
I asked that myself sometime ago too...
still haven''t found the answer, i heard it''s inhomogen or not...

something like that...

would be nice, if some Maths Guru could explain that for us non-mathematical Programmers...
thx
cya,

Phil

Share this post


Link to post
Share on other sites
it depends on what you wanted to do with it.
if color, it''d be alpha channel
if animation, it''d be time
if quaternion, it''d be the angle of rotation

a2k

Share this post


Link to post
Share on other sites
it''s pretty simple,w is the scale factor.
so if you modify it the size of the object will change .
i''m not totally sure of this becuase i don''t find where i have red it now.

Share this post


Link to post
Share on other sites
ok, from the superbible (chapter 5):

glVertex4(Xo, Yo, Zo, Wo) the original vertex data

MODELVIEW MATRIX
->(Xe, Ye, Ze, We) transformed eye coordinates

PROJECTION MATRIX
->(Xc, Yc, Zc, Wc) Clip coordinates

PERSPECTIVE DIVISION
->(Xc/Wc, Yc/Wc, Zc/Wc) Normalized device coordinates

VIEWPORT TRANSFORMATION
->window coordinates.

so, the w variable is a scaling variable which affects x, y, and z.

I think you could use Vertex4(x, y, z, 2) instead of Scale(2, 2, 2), so you''d reduce the number of calls you had to make, and you''d be able to affect the scale from inside glBegin()/glEnd()...
and its probably faster than Vertex3(2*x, 2*y, 2*z)

this may have helped....i hope it did

alistair

Share this post


Link to post
Share on other sites
(x,y,z,w) are called homogenous coordinates. They are there so that you can perform matrix operations with 4x4 matrices. You can pretty much turn any 3x3 into an appropriate 4x4 by adding the 1 to the lower right indice of a matrix. Consult a decent math book for a better explanation (or a computer graphics book).

-BacksideSnap-

Share this post


Link to post
Share on other sites
Thats right.. its because they are homogenious co-ordinates.

If were only to use a 3x3 matrix, we could scale in 3d, and rotate in 3d, but not move in 3d. Thats because you have to add to a position to move it, not multiply. So instead of the equation being x+y+z=0, it would be x+y+z=a where a is some number. In other words, its there so the maths can be done.. dont worry about it

BTW, the reason you can still scale in a 3x3 is because you multiply the diagonal by a number.. since w is in the last spot, it has to mulitplyed too.. but it will still work without it.

Share this post


Link to post
Share on other sites