Why is there a W term in a lot of 3D API’s Vector class (i.e. Vector4(x, y, z, w) ) ? Are there math operations that absolutely require the W term?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is a special representation of a point in 3D space, called homogeneous coordinates.
They are just another way to describe a point in 3D space. They are used a lot in 3D graphics because they have a few advantages: they make some formulas simpler, and they allow you to represent a “point at infinity” (or “line at infinity” etc. depending on dimension).
See e.g. this article for an explanation:
http://andrewharvey4.wordpress.com/2008/09/29/xyzw-in-opengldirect3d-homogeneous-coordinates/
Wikipedia also gives a nice overview (warning, some fun but serious math in there):
http://en.wikipedia.org/wiki/Homogeneous_coordinates
http://en.wikipedia.org/wiki/Projective_geometry
(projective geometry is the underlying theory for homogeneous coordinates)
Bonus fact:
The reason that transformations of objects from our familiar 3D space are actually easier using homogeneous coordinates is because, contrary to intuition, projective geometry avoids some of the special cases that you need in Euclidean geometry. For details, see articles above, or any decent math book on projective geometry :-).