4 Element Vector (3D Math)
Asked Answered
A

1

10

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?

Ainslee answered 2/10, 2010 at 22:21 Comment(0)
B
20

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

Bendix answered 2/10, 2010 at 22:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.