views:

207

answers:

5

What (if any) is the relationship between vectors used in programming languages (e.g. arrays) and vector graphics?

Why do they share the term vector? Does it represent some analogous aspect of their nature or is it coincidence?

When thinking about it, a bitmap image would fit the term vector graphic better since it's represented by an array of pixels..

+2  A: 

A vector is an ordered group of values, such as <1, 2, 3>. It is different to an array because it is a fixed size and represents a number of values and their position in the vector is significant. An array is just an ordered collection of things. The order of elements matters but not their position. The things in it are generally all of the same type.

If the vector represented <# apples, # oranges, # pears> then it could be interpreted as <1 apple, 2 oranges, 3 pears>. If it represented <X position, Y position, Z position> then the above might mean <1 in the X axis, 2 in the Y axiz, 3 in the Z axis> (a Euclidean vector). Thus vectors can represent co-ordinates in arbitrary dimensions and are used to store information in vector graphics.

Joe
But what about stl::vector in C++? It works just like an array and doesn't by design specify "position" data. I've also heard arrays being called vectors and vice versa.
sharkin
Note that I'm a C++ fan, but I would say: never rely on how C++ names things ;-) In C++, an std::vector is just an array, for which the memory is automatically managed.
Carl Seleborg
I think this is just semantics. An std:vector does have position information (the index); the same with an array. While there may not be any meaning attached to this positional information in code, there is certainly meaning to the programmer.
Ron Warholic
a rasterized image stores data as a set of vectors, you haven't gotten at what the Vector in Vector Graphics signifies.
klochner
@klochner: No, a rasterized image is comprised of a single (one-dimensional) array of pixels, where each array segment represents the color components in various distribution of byte order and size.
sharkin
@RA - what I meant was that each pixel is a vector quantity defining the RGB value at that point, i.e., a vector in color space.
klochner
+3  A: 

They share a root meaning in mathematics.

The graphics meaning (a continuously valued offset from on arbitrary position in space), derives from the fact that you use mathematical vectors to represent it (e.g. one to represent the starting point and to represent the offset).

The programming language meaning (an ordered set of numbers) is one way of writing down the mathematical version.

dmckee
+8  A: 

a vector is a set of values, which "normally" (mathematicians would kill me) represent the coefficients of a linear combination of things (functions, or other vectors).

For example, when you say

[4, 3, 7]

and your basis is the set of power exponents of x (i.e. 1, x, x^2, x^3 etc...), this vector expresses the polynom

4 + 3x + 7 x^2

if you use a different basis, for example arbitrary directions in 3d space, that same vector expresses a direction in 3d space.

4i + 3j + 7k

(lateral consideration: please note that 3d space is a finite vectorial space of dimension 3, while the polynomial space is an infinite vectorial space, or a Hilbert space as it is better defined)

This is a vector (think an arrow) pointing in a specific direction in space, from an origin to an end. The convention is that i,j, and k are the so called basis set vectors of the 3d vectorial space, where the coordinates of each point are expressed as x,y and z. In other words, every point in space, and every direction in space, can be expressed with a triple of numbers (a vector) x, y, z which represents the spatial vector x * i + y * j + z * k.

In vector graphics, you express graphical entities not as a grid of pixel (raster graphics) but as mathematical formulas. A curve is described as a parametrized mathematical expression. This opens up a lot of nice properties for displaying, because a mathematical description has basically infinite resolution. You can also apply mathematical transformation on these entities, like rotation, without ruining its description, and these transformations are deeply rooted in linear algebra, the discipline governing transformation of vectorial spaces, matrices and so on...

Stefano Borini
This is the best of the explanations given.
Ankur Goel
A: 

I guess it comes from the mathematical term 'vector', which is a geometrical concept. When you operate on mathematical vectors, which (in theory) have their values in continuous domains, instead of on discrete pixels, you can compute with arbitrary precision. In a graphics application, it means that you can retain precise point positions regardless of the zoom factor you are displaying your picture at.

Carl Seleborg
A: 

Vector graphic is different that 'normal' graphic because it can be zoomed without aliasing. It is called vector graphic because each line or other object are represented by a vector instead of the "by pixel" normal grahic.

David Brunelle