4 Element Vector (3D Math)

不打扰是莪最后的温柔 提交于 2020-08-22 04:43:13

问题


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?


回答1:


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 :-).



来源:https://stackoverflow.com/questions/3847743/4-element-vector-3d-math

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!