4 Element Vector (3D Math)
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?
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 :-).
精彩评论