Jump to content
• Advertisement

# Can someone explain homogeneous coordinates in the context of computer graphics?

This topic is 3035 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 have to admit that I have never used them and do not fully understand them or why they are used. I did a Google search, but I turned up more math than practical explanations and examples. I'm just lost as to both how and why this projects a 3D vertex onto a 2D plane: x' = x / w; y' = y / w; z' = z / w; In most cases that I've seen, 'w' equals 1.0 or 0.0. Not only that, but to project a 3D vertex into 2D screen coordinates, don't you have to divide by z? When and how does z factor in? If w is the depth coordinate, why not replace it with z and go back to (x,y,z) coordinates? This whole process mystifies me. The "Poor man's projection" is so much more clear and easy to understand. However, if this is the way it is done now, I'd really like to know the basics behind it. Can someone explain this in detail? A small code example showing projections of 3D vertices onto the screen would be nice, if possible.

#### Share this post

##### Share on other sites
Advertisement
The operation you give there doesn't project a 3D vertex onto a 2D plane. It projects a 4D homogeneous point onto the 3D hyperplane w=1. To actually apply the camera perspective you first need to apply a perspective transform matrix (see last paragraph).

Homogeneous coordinates really just allow infinitely far ("ideal") points to be represented. Working in a space that supports these allows you to perform linear transforms in 4D (or one dimension up, generally) that map to non-linear transforms in 3D (or one dimension lower, generally), once the division by w is performed. For example, if you shear x, y and z against w in the "4D" homogeneous space, you affect a translation in "3D" (quotes are used since a point in such a homogeneous space is not technically 4D, since all points are the same to multiples by a positive scalar).

The "perspective transform" matrix that is commonly used (google for it) is also not actually a projection. It performs a 4D linear transform that warps the space so that points near the view plane scale larger in X and Y than points at the far plane, effectively warping a frustum into a cuboid. A true projection (one that is idempotent) would lose the depth information, whereas this sort of transform retains it for use in the z-buffer (or w-buffer). The actual true projection then comes in afterwards by simply ommitting the z-value when rasterizing the triangle on 2D (although the z-value is still interpolated over the z-buffer).

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
2. 2
Rutin
24
3. 3
4. 4
JoeJ
18
5. 5
• Advertisement

• 14
• 23
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631768
• Total Posts
3002241
×

## 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!