11

I often see the words 'vector' and 'vertex' (plural 'vertices') being used in 3D programming contexts.

From what I can tell, they both describe a point in n-dimensional space. The XNA framework for example has Vector2, Vector3 and Vector4 classes, but there doesn't seem to be a Vertex class.

What is the exact difference between a vector and a vertex?

lesderid
  • 3,081
  • 7
  • 36
  • 62

1 Answers1

20

A 'vector' is a mathematical concept; crudely, it represents a displacement in some coordinate space. A vertex is an element of some 3D (or 2D, really) geometry which typically has a position and some other attributes (color, texture coordinates, et cetera).

The position of a vertex (and thus sometimes the vertex itself) can be represented by a vector if one assumes the vector is a displacement from the origin of the coordinate system. Sometimes people call this representation of a vector a "position vector."

So, roughly, the difference is that vectors can be used to describe (in full or in part) a vertex.

  • 5
    The important part to note here is that a vector only contains the positional data, while a vertex can (and usually does) contain more information than just its position. – CodeHxr May 17 '12 at 18:39
  • In XNA, and possibly other 3D graphics frameworks, there exists a Vector4 class. Since humans can still only observe 3 spatial dimensions, is the Vector4 class used for vertices then? If so, why is it called a Vector? – lesderid May 18 '12 at 08:08
  • 3
    @lesderid More formally, vectors are an element of a vector space and can have n coordinates. While it is true that 1, 2 and 3 dimensional vectors happen to have convenient geometrical relationships to the 3D space humans can visualize, that itself is not an intrinsic property of vectors. That said, 4-component vectors are commonly used as vertex attributes (typically for position or color attributes). They're useful for position because they allow for 4x4 matrix transforms and they're useful for colors just because they happen to be able to store four components (RGBA). –  May 18 '12 at 15:37
  • 3
    A vertex might also mean something more general, as in vertices of a graph, for example. – lysergic-acid May 19 '12 at 12:45
  • Vector can describe displacement to SOME point. That point *may* be [vertex](http://en.wikipedia.org/wiki/Vertex_(geometry)) or *may be not* { for example mid-point of line segment}. – Agnius Vasiliauskas May 28 '12 at 14:23
  • 3
    @Josh You could justify a Vector's use to store color information too, as representing a displacement in color space. – Anne Quinn Jul 27 '12 at 19:40