Not logged in, Join Here! or Log In Below:  
News Articles Search    

 Home / 3D Theory & Graphics / Vectors, vertices and a geek Account Manager
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.

August 23, 1999, 12:08 PM

Ultimately, it really doesn't matter, but I wondering what people in general did with vectors and vertices.

When I read Hook's book on 3d graphics, I cringed when he said that there was no difference between a vector and a vertex. The truth is there is a TON of difference between the two.

But does it matter?

In my own code, I have a CVector3 class that I use for both vectors and vertices. Since the code is all the same for a vertex and vector why make 2 classes?

So here is my question...

In your code, do you make a distinction between a vector and a vertex OR do you use the same class for both OR do you have one class and another simple class wrapper or typedef? (Personally I consider choice 1 and 3 the same since you still recognize there is a difference).


Jaap Suter

August 23, 1999, 12:25 PM


In my opinion:

vector is:
float x, y, z, w;
vertex is:
vector (position) + vector (vertexnormal) + texturecoordinates + color + alpha value

Jaap Suter

Tim Smith

August 23, 1999, 03:46 PM

Well, all that other stuff isn't part of the definition of a vertex, but from the prospective of a graphics engine it is valid.

My question was really about conceptual difference between a vertex and a vector. Both are an n dimensional value. However, they mean two totally different things mathematically. But, you did answer my question in your definition of a vertex. Thanks...


Jaap Suter

August 23, 1999, 05:24 PM


then I probably didn't understand the question correctly.

Ofcourse there is a mathematical difference between a vertex and a vector. But if you compare the computational representation they look the same. Unless you account for all I did in the previous posts.

We can go into a huge debate about this (which I would like) but I actually store the position of a vertex as a cVector object.


Jaap Suter


August 24, 1999, 12:40 AM

Mathematical perspective:

Computer graphics by defenition exist in a VECTOR space. In a vector space all points are considered vectors from the origin. There is NO SUCH THING as a point in linear algebra. Therefore there isn't any destinction between a vertex and a vector. A vertex has color and texture coordinates so its basically a vector that exists in 3 spaces(world, texture, color). That is the only difference. I would point out to you that matrix transformations on anything but vectors do not exist. This sounds strange but if you consider that a vector is a 1 covariant(or contravariant, depends whether its row or column) tensor and a matrix is a 1 covariant and 1 contravariant tensor it makes sense. Tensors, since they are invariant in any coordinate system(such as a linear transform, ie a matrix!) have basis vectors attached to them, though this is implicit in most 3D engines, they just dont worry about it. Therefore tensors only exist in vector spaces. Since a point is not vector space dependant it is not a tensor. There is no multiplication sense between a point and a tensor(even a 2 valence, ie matrix). Since you can multiply anything by a matrix in a 3D engine everything is in vector space. And mathematically therefore there is no distinction between a vector and a vertex. And since nothing else except math exists, like mister Einstein pointed out, this is true. One other note: vertex normals are not real. They are a representation of the surface normal at that point to the true curvature of the object, which is not always desirable by the way. They are stored in the vertex structure because of convenience but are IN NO WAY affiliated with the vertex. A normal to a vector is an oxymoron:)

As to the engine point of view, I use a separate vertex structure with some elaboration on texture coords since you need multiple passes, and a separate vector structure. I cant see how you can reuse the vector in the vertex for serious code, since what happens to a vector is very different than a vertex. The vertices are the ones that get rendered, so if you write say a separate driver that you can change to implement another graphics api(i do this) you need a distinct vertex structure to communicate with it. The main reasons are mostly program related and not mathematic though. There isnt that big a distinction between them except that the vertex exists in 3 spaces instead of 1, all of different dimensions(color is 4-rgba, and texture is 2-st, and world is 3-xyz and a homogenius so 3.5 i guess...), though it's still basically a vector. It depends on how you want to structure your stuff. Just one note on this: whatever the structure, do it well! Well, no sh*t sherlock:)

Hope this clarifies things,
- Raven

Jaap Suter

August 24, 1999, 06:52 AM

My compliments.

But ehh... what the ^&*( is a tensor?

Jaap Suter


August 24, 1999, 10:43 AM

Excellent information, however, there is one point I must disagree with.

In my linear algebra books, they specifically talk about vertices and vectors when defining vector space. Their approach was to basically state that the difference are mathematically unimportant to the subject of linear algebra. However, in no way did they say that vertices don't exist in vector space. However, for the purpose of linear algebra making a distinction would be cumbersome and counter productive.

There are differences between a vertex and a vector. Since there representation and operators are nearly 100% identical, the differences tend to be overlooked.

vector: a quantity that has magnitude and direction and that is commonly represented by a directed line segment whose length represents the magnitude and whose orientation in space represents the direction; broadly : an element of a vector space

vertex: the point of intersection of the two sides of an angle, or of three or more sides of a geometric solid

(didn't mean for this to turn into a math discussion)



August 24, 1999, 11:34 AM

Had a long talk with my brother about this subject. He has a MS in math. That doesn't make him an expert, but it beats my BS in math (pun intended).

1) Technically, vertices do not exist vector space.

2) Practically, vertices are used in vector operations as long as there is a well defined conversion between the two. Usually, this conversion is an implicit conversion (the conversion most all of our 3d engines use). I think many 3d engine programmers are unaware that they are playing fast and loose with vertices and are using implicit conversions to and from vectors to utilize vector space operations. After all, the routine is called glVertex, not glVector.

So, in many ways we are both correct and wrong. (Don't you just hate that =).



August 24, 1999, 02:10 PM

Excellent point. If you consider a vertex to be the intersection of two vectors then you can consider it as a point. Though it is still a vector from the origin... Though this discussion leads nowhere.

As to programming i can just repeat what i said before. it all depends on your engine.

And, unrealted question. Does anyone know if Direct3D or Opengl have any problems running from within a dll and not a process which is static in memory?

- Raven


August 24, 1999, 02:14 PM

Yeah, it is a worthless discussion. Hence the subject =)

It was more idle wondering on my part that any earth shaking question requiring an answer.



August 24, 1999, 02:18 PM

>>But ehh... what the ^&*( is a tensor?
Ok, crash course. A tensor is an invariant. It is basically like an array on a computer. A matrix is a 2 dimensional array, or a 2 valence(more on this later) tensor. A vector is a 1-dimensional or a 1 valence. In a bezier curve you have a geometry matrix the elements of which are vectors, ie a 3-dimensional array or a 3 valence tensor. Hence the name tensor-product surfaces. Now, a column vector we designate as a 1 covariant tensor. Therefore a matrix is a 1 covariant 1 contravariant tensor. A bezier geometry matrix is a 1 covariant 2 contravariant tensor(or the other way around). The valence of a tensor is the covariance+contravariance, ie the dimension of the array. A simple way to look at covariance and contravariance is that covariant elements of the tensor are "perpendicular" to the contravariant, like the rows and columns in a matrix. There is an entire subject of tensor calculus because there is no simple way to multiply an 8 valence tensor by a 7 valence tensor. I have to admit that i have never seen a tensor of valence greater than 3. Since tensors are invariant they are defined as a collection of numbers with the above rules and a basis. The numbers are valid only in that basis, and in order to apply the tensor in an isomorphic basis to the original, you need to transform the tensor components. Hence a matrix is not invariant but a linear transformation is. That is why you cant apply a world-space matrix to local space, but you can if you multiply the world-space matrix by the transform to local space.

Hope this helps,
- Raven

This thread contains 11 messages.
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.