Public Group

# vertex position values... x, y, z, and "w"?

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

## Recommended Posts

In vertices, I've heard that there's a fourth value that can be passed for creating a vertex (like glVertex4d()), and was wondering what it was used for. May somebody tell me? Thank you in advance.

##### Share on other sites
w is called the "homogenous coordinate".

From the red book:
Quote:
 As long as w is nonzero, the homogeneous vertex (x, y, z, w)T corresponds to the three-dimensional point (x/w, y/w, z/w)T. If w = 0.0, it corresponds to no euclidean point, but rather to some idealized "point at infinity." To understand this point at infinity, consider the point (1, 2, 0, 0), and note that the sequence of points (1, 2, 0, 1), (1, 2, 0, 0.01), and (1, 2.0, 0.0, 0.0001), corresponds to the euclidean points (1, 2), (100, 200), and (10000, 20000). This sequence represents points rapidly moving toward infinity along the line 2x = y. Thus, you can think of (1, 2, 0, 0) as the point at infinity in the direction of that line.

Basically, you'll only use the w-component on a range of 0 to 1. A use for it, off the top of my head, is for extruding shadow volumes. So, for an arbitrary closed model, you can set vertices facing the light's w to 1, so they are drawn in regular coordinate space. For vertices facing away from the light, setting the w coordinate to 0 essentially creates a volume extruded away from the light through the model, to infinity. Add in a few stencil operations, and you get cheap and easy shadowing.

##### Share on other sites
These are known as homogeneous coordinates. A vector (x,y,z) in R3 can be uniquely mapped onto the vector (x,y,z,1) in R4. Other vectors in R4 can be projected onto the hyperplane w = 1 by (x,y,z,w) -> (x/w,y/w,z/w,1). In this way R4 - {0} is partitioned into equivalence classes, where each class is represented by the projection (x,y,z,1) and its members lie on a line in R4 passing through the origin. This is illustrated in the following image:

It is important to note that any 3x3 linear transformation can be represented by a 4x4 homogeneous matrix, where the vector to be transformed is represented by its image in R4 under the above mapping. However, homogenous matrices can also represent the more general affine transformations, which intuitively consist of a linear transformation followed by a translation.

As an example, suppose we want to translate the vector (x,y) in R2 by the vector (a,b) using matrix multiplication; that is, we want to compute (x+a,y+b). This can be accomplished using homogeneous coordinates:

So the idea behind homogeneous coordinates is they allow us to represent the more general affine transformations using only matrix multiplication.

1. 1
2. 2
3. 3
4. 4
5. 5
Rutin
18

• 11
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631420
• Total Posts
2999990
×