Jump to content
  • Advertisement
Sign in to follow this  
kelaklub

The 4th dimension

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
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.

Share this post


Link to post
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 this post


Link to post
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".

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!