#### Archived

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

# Someone please explain homogeneous coords.

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

## Recommended Posts

I have a general idea about the w coord and how to switch back and forth from Cartesian to homogeneous. But, I seem to be missing the high level concept. Most things I read simply say, if it''s a point throw a w of 1 at the end, if it''s a vector throw a w-val of 0. But com''on, for 2 simple vals why not store it as a bool. OR...is the concept that I haven''t found documented, something along the lines that dependent on the distance from the origin/camera, the w-coord ranges from 0.0f to 1.0f. Argh! I don''t get what it helps.

##### Share on other sites
Well, I don''t know how much of a linear algebra background you have, but the homogenous coordinate is generally useful for the translation transformation, and perspective projection. We would like to represent translation as a matrix so we can compose it easily with other transformations like scaling and rotations (Otherwise we could simply add a delta to each point). Unfortunately, a linear transformation always transforms the 0 vector to itself. It seems at first that translation would be impossible with linear transformations, but there''s a slick trick we can pull by embedding our 3d universe in a 4 dimensional vector space with everything on the w=1 plane. Now we can shift this plane around with a shear matrix, and this will amount to translating points in the space.

Perspective is a little weirder to explain, but essentially, you tilt the w=1 plane, and reproject points back onto that plane.

##### Share on other sites
The fourth w, can be used as a weight as well.

In RL, homogeneous coordnates are really just a hack so that 4x4 matrices work. Its far easier to do things with 4x4 than 3x3, so we add an extra digit.

When you get advance, they also have other uses, but its hard to explain why. NURBS curves sometimes wind up with control points with the w value is not always zero or one.

##### Share on other sites
Homogeneous coordinates are used because they allow you to do all the standard transformations (rotation, translation, shear) using similar sized matrices (4x4 in 3D).

[x y z w]t is equivalent to [x/w y/w z/w]t

So a w of 0 describes an infinite (directional) vector, as you mention, but w can also used to scale the overall vector.

Edit: The extra dimension is useful for perspective projection. When you do the perspective transformation, you transform from the hyperplane H=1 to some other hyperplane, then project from 4D space back to 3D space by projecting back to the hyperplane H=1. You can then project to 2D (window) space just by discarding the Z and W coordinate values.

[edited by - benjamin bunny on April 19, 2003 10:35:23 PM]

##### Share on other sites
http://developer.nvidia.com/view.asp?IO=understanding_w

##### Share on other sites
The reason why points are given a w value of 1 and direction vectors are given a w value of 0 is that points should be affected by translation but direction vectors should not.

A 4x4 transformation matrix usually looks like this:

[ M11, M12, M13, Tx ]
[ M21, M22, M23, Ty ]
[ m31, M32, M33, Tz ]
[ 0, 0, 0, 1 ]

You will notice that a vector''s w coordinate multiplies the T values in the matrix above. If the w coordinate is 1, the values Tx, Ty, and Tz are added to the x, y, and z values of the final result, respectively. If the w coordinate is 0, the values Tx, Ty, and Tz are NOT added to the final result. Since the T values represent a translation, what happens is that points are translated but direction vectors are not.

##### Share on other sites
quote:
Original post by Anonymous Poster
The reason why points are given a w value of 1 and direction vectors are given a w value of 0 is that points should be affected by translation but direction vectors should not.

herm...

Standard maths : Vector AB = point B - point A, so if points A and B both have w=1, AB necessarily have w = 0

-* So many things to do, so little time to spend. *-

##### Share on other sites
quote:
Original post by Ingenu
herm...

Standard maths : Vector AB = point B - point A, so if points A and B both have w=1, AB necessarily have w = 0
Of course, but that doesn''t invalidate anything I said. Besides, not all direction vectors are obtained from the difference between two points, which means that assigning w = 0 explicitly to direction vectors is sometimes necessary.

1. 1
2. 2
3. 3
Rutin
15
4. 4
khawk
14
5. 5
frob
12

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633662
• Total Posts
3013228
×