# The 4th dimension

This topic is 4414 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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.

##### Share on other sites
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.

##### Share on other sites
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

##### Share on other sites
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".

1. 1
Rutin
45
2. 2
3. 3
4. 4
5. 5
JoeJ
19

• 11
• 13
• 9
• 10
• 12
• ### Forum Statistics

• Total Topics
633002
• Total Posts
3009823
• ### Who's Online (See full list)

There are no registered users currently online

×