xyzw

Started by
7 comments, last by Seaman 23 years, 8 months ago
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.
Advertisement
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
Visit Rarebyte! and no!, there are NO kangaroos in Austria (I got this question a few times over in the states ;) )
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
------------------General Equation, this is Private Function reporting for duty, sir!a2k
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.
If its scale then would that mak it fit in the matrix like this:-
[W 0 0 0]
[0 W 0 0]
[0 0 W 0]
[x y z W]
Duno why but would seem to make some sense.
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
(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-
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.
My curiosity has been cured, thanks.

This topic is closed to new replies.

Advertisement