The 4th dimension

Started by
2 comments, last by crowley9 17 years, 7 months ago
I am in the process of implementing a geometric library. I took on this project as a way of improving my programming skills and understanding of graphics. Some questions for you, gods of gaming... I heard that in order to apply matrix transformations to points or vectors there is the need of a fourth component, such that... (x, y, z, 0) implies a vector and (x, y, z, 1) implies a point Now when we attempt to scale a point or vector by multiplying it with some constant, does that also have to be applied to this fourth parameter? For example... Constant (c) * vector (c * x, c * y, c * z, c * 0) = (c * x, c * y, c * z, 0) and constant (c) * point (c * x, c * y, c * z, c * 1) = (c * x, c * y, c * z, c) Does this even matter or could we just have done... Constant (c) * vector (c * x, c * y, c * z, 0) = (c * x, c * y, c * z, 0) and constant (c) * point (c * x, c * y, c * z, 1) = (c * x, c * y, c * z, 1) ...and left the 4th parameter alone.
Advertisement
The 4th parameter is used to make matrix math work correctly with 4x4 matrices. Sort of like adding a link to a chain so you can hula with it. Okay, really bad analogy. But the values do not need modified in any way when modifying other attributes. Well, at least not in any traditional scaling, rotating, or translating modifications.
Quote:Original post by kelaklubNow when we attempt to scale a point or vector by multiplying it with some constant, does that also have to be applied to this fourth parameter? For example...


The fourth coordinate is not a true coordinate, it is an homogenous coordinate.

That means that {x, y, z, 1} is equal (once rapported to 3d space) to {cx, cy, cz, c} with c non zero constant.

So basically if you multiply all four coordinates by the same value, you've achieved a wonderful nothing.

Also beware because of this fourth coordinate you need to be careful when adding a vector to a point (translation), if you just do : {cx + u, cy + v, cz + w, c), you end up with the wrong translation.
But this works fine if you use the 4d space transform :

1 0 0 u
0 1 0 v
0 0 1 w
0 0 0 1

which translates to {cx + cu, cy + cv, cz + cw, c}

LeGreg
To elaborate: if you scale all 4 components of a homogeneous point/vector by positive scalar c, you land up with the same homogenous element (as noted by LeGreg). You want to multiply only the first 3 components if you want to scale.

Also, (x, y, z, 0) doesn't really imply a vector as such. It implies a direction without magnitude - often thought of as an infinitely far away point in the given direction.

If you want to find out more about this you can web search for "homogeneous coordinates" or "projective geometry".

This topic is closed to new replies.

Advertisement