what a (math) vector is exactly?

Started by
17 comments, last by graveyard filla 19 years, 7 months ago
(Not an useful post, mainly ramblings...)

Vectors are objects that have the following properties:

- They can be multiplied by a number, which gives you another vector.
- They can be added together, which also gives you vectors.

They are widely used to represent movement, either as a velocity (movement per time step) or as overall movement (from A to B).

Two common misconceptions are:
* A vector has a dimension. This is wrong: the notion of "dimension" is applied to a set of vectors, and is the number of vectors you need in order to be able to describe all the vectors in that set (that is, the number of coordinates to describe objects in that set). [For instance, what is the dimension of the polynomial 2X+3?] HOWEVER, when programming, you create a "vector" type to describe vectors from a set, and so the "2D" in "vector2D" means you will use this object to describe vectors from a 2D plane.
* A vector has a direction and a magnitude. While vectors can have a magnitude (for most useful purposes in game programming, they have one, and standard euclidean distance is used), not all have a direction. The 0 vector, for instance, has nothing that can be defined as "a" direction. And while you could define "direction" for a n-th degree polynomial or a continuous function (which are vectors), it wouldn't really make sense, would it?

However, to describe lines, planes and points, vectors are not enough. This is why the concept of affine space was introduced. An affine space contains a special object, which could be called the center, or the origin. It serves as an absolute reference for everything affine.

Once the origin is there, points are defined as being equivalent of vectors, but only in some ways:

- A point contains a vector, that defines it entirely. That vector is the "movement" that allowes you to move from the Origin to that point.
- However, unlike vectors, you do not add points together. You also cannot multiply points by something.
- You can "substract" two points from each other. The result of this operation is the vector that allows you to move from one point to the other: A-B is the vector that moves from B to A. By using vector addition rules, it is also the vector that defines A, minus the vector that defines B.

Also, an affine space introduces distance. The distance between A and B is the magnitude of B-A (or A-B). This is useful if you want to check for a collision, for instance.

Two common misconceptions about points:
* I can add points together. Addition is not defined for points (neither is multiplying by a number. You could define these operations yourself, but they don't make much sense. Applying transforms to points (translation, rotation, scaling, and many others), however, does.
* A point is a vector. Again, no. Sure, a point is defined by a vector, but don't forget that behind the scenes, it is also defined by the definition of the origin. Maybe you could decide to store the origin of the point along with the position vector, to allow for multiple origins? This happens quite often in physics, for instance, where the vector corresponding to a point depends on the origin you choose.

Food for thought:
Not all games use euclidean magnitudes for vectors. Some tile-based games use manhattan, or "1", distance (ie x+y magnitude), others use "infinite" distance (ie max(x,y)). Euclidean magnitude is the "2" distance.
Advertisement
Quote:Original post by ToohrVyk
*** omitted humungess rambling ***


oh man i feel sorry for graveyard filla now [lol]
Quote:Original post by ToohrVyk
(Not an useful post, mainly ramblings...)

Vectors are objects that have the following properties:

- They can be multiplied by a number, which gives you another vector.
- They can be added together, which also gives you vectors.

They are widely used to represent movement, either as a velocity (movement per time step) or as overall movement (from A to B).

Two common misconceptions are:
...


* A vector has a direction and a magnitude.


That a misconception? What sources have you which state this? Vector Analysis was developed mostly by physicists and to say that what is taught in the physics books of the highest regard is a misconception is highly improper. How can the creators of a concept misconceive it?

-------------

A vector is simply a quantity which can be described with a magnitude and a direction. For example, the players speed is not a vector because it is not possesed of a direction (you could only represent it with a float or int etc.). The players velocity is, however, a vector, since it will have a direction (you can go v.x and v.y etc.). The players position is a vector because it is defined in terms of x and y and thus has a direction. The magnitude of this vector would be the distance of the player from the origin. So for velocity the vector points in the direction of motion and gives the amoiunt of this change. For position the vector points to some location a certain distance away from the origin. A vector is not a point, a vector can point at a point however.

So if the player is at Point (10,10) then it can be said that a vector exists which points from the origin at him or her.
_____________|\     | \                | _\/ |    (10,10)|   

Vectors can also be posessed of different (local) coordinate systems. For example the velocity vector (in one timestep) can be thought of to have an origin in the Players position and point to a point speed (per time step) distance away. This is a loose explanation but gets the point across, I hope.

__________|\    _ (13,7)| \    /\ <-------Velocity Vector, Say it is (3 ,-3) Points at  players new position, so northeast key..               |  _\/ |   (10,10)|    
I didn't say vectors never had a direction, since it is quite natural to introduce a direction for vectors in the "usual" 2D and 3D spaces.

However, vectors are not restricted to their initial field of application (physics), as many objects in mathematics also have the same properies as the vectors used in physics, and as such are called vectors too (not to say that IMHO, much more work is done in mathematics using vectors, than is in physics).

What is the direction of x -> sqrt(x)? Of 2X+3? Of the linear rotation of angle pi in the plane? Of a system of linear homogenous equations? Of the solutions of a differential homogenous equation? Of a complex number?

Sure, you can define direction mathematically, regardless of the actual nature of the vectors you are considering, and in the case of 2D and 3D spaces this definition will overlap with the intuitive definition of direction, and that's good. For all the purposes of most physics books, all the vectors they will explicitly use impicitly have a direction. But this doesn't mean that in many other cases this definition will be counter-intuitive. Returning to one of my examples above, do the complex numbers 1 and i have the same direction? No, if you consider C as a R-vectorial space, yes, if you consider C as a C-vectorial space. Or, if you prefer an example from physics, when representing electromagnetic waves, are we using C-vectorial spaces, or R-vectorial spaces? Both.

My point is not to bash renowned physics books. On the other hand, I don't see why a physics book would delve into the specifics of mathematical vectors. In almost all cases in physics, a vector has a direction. Now, in math/computer science, not all vectors have a direction (and by this, I mean an acceptable, intuitive one, not a purely mathematical one).

Besides, the direction/length way of representing vectors has always had a problem with representing 0, which leads me to say that "direction" isn't very clearly defined for 0. If you don't move, what direction do you move in?

EDIT: I also find it quite humorous that you state vectors have a direction and magnitude, and then proceed to thoroughly avoid the direction/magnitude representation of vectors and use Cartesian coordinates instead. The direction/magnitude of a vector in 2D is usually (Angle,mangnitude), in 3D (Angle,Angle,Magnitude). "Seeing" direction and magnitude in an (x,y,z) vector is awkward.
ToohrVyk has a point. For most game programmer applications, you never touch anything more than the simplified direction and magnitude. However, the OP did ask what a vector is exactly. And although he did not know what that implies, he should get it.
True, the simple approach is enough for a lot of applications, but if he asks for it, he should get the whole story. And although you can always have an isomorphism into a simple X^n (let X be a suitable field, or however you call that in English), talking about angles and magnitude is possible but sometimes useless. You can canonically represent the polynom 3x^2 + 4x + 1 as the vector (3, 4, 1), but it does not make much sense to talk about those concepts. And what do you do in those cases where the dimension is infinite? For example the vector space of continuous functions over the real numbers? Unless you add in a scalar product, you can't talk about angle and magnitude, and even if you have one, the resulting interpretations for angle and magnitude are not always too helpful and intuitive.

Talking about angle and magnitude surely helps for a lot of purposes and is enough for some applications. But the mathematical definition of vectors works completely differently and allows for a lot of abstraction (which you need in those other not so simple cases). It's too much work (and too messy in pure text) to properly introduce all those concepts needed, but they should be mentioned.
I concede that in mathematics a vector need not posses a magnitude or direction as when I looked up the mathematical definition it was not defined so but rather as an element of vector space. I do not agree however, that it is a misconception that a vector has an angle or a magnitude because in physics, they do.

This is simply a case of colliding terminology. Here is an extreme example; in math a product is the result of a set of multiplication operations. In chemistry a product is the result of a chemical reaction. If I were to go to a chemistry forum and ask what a product was and someone were to say that it is a common misconception that a product needs to be a substance because in mathematics the product can simply be a number, would that be appropriate? No, because in chemistry a product is defined as something different than it is in math.

It goes to follow that since most all the applications of vectors in game programming are of the type used by engineers that the physics definition be given. If I am learning English and I were to ask what H is, you do not tell me that it is a symbol for the element hydrogen, now do you? Ofcourse not, your post was outside the scope of graveyard filla's question, it more likely than not causes confusion.

Quote:Original post by ToohrVyk
Or, if you prefer an example from physics, when representing electromagnetic waves, are we using C-vectorial spaces, or R-vectorial spaces? Both.


Indeed waves are represented in the complex plane in physics but that it is simply because the calculations are far simpler to perform than if the waves were left in their trigonometric form. As for the representation of the implied results in reality, either the real or complex parts suffice. Also, there is a clashing of concepts in how you relate complex representation and electromagnetic waves. Light, an electromagnetic wave, is a physical phenemenom defined in terms of its (the) appropriate units. I'll note also that electormagnetic waves are possesed of a wave vector, which have direction and magnitude.

Quote:Original post by ToohrVyk
EDIT: I also find it quite humorous that you state vectors have a direction and magnitude, and then proceed to thoroughly avoid the direction/magnitude representation of vectors and use Cartesian coordinates instead.


I purposely worked in cartesian coordinates because I am aware of the rpg graveyard filla is working on and describing vectors in that manner would be the most relevant course. The diagrams do, however, show vectors with magnitudes and directions in a visual format. Asides, representing and manipulating vectors in polar or spherical coordinates requires a bit of mental acrobatics as you are well aware. The simplest way to define a vector (especially to a game programmer) is if a quantity can be broken down to its unit components (x and y) then it is a vector.

Anyway coming from a mostly physics background I had never run into a definition of a vector that did not define it in terms of magnitude and direction nor seen an application of it in which such was not the case. I thus found it difficult to envision a vector as anything otherwise, I am therefore thankful for your expanding the scope of my knowledge of vectors and extending it to different domains. But I still think your definition was too hardcore for graveyard filla's needs.

-------A vector is:---
In physics a vector is a quantity posseed of both a magnitude and direction.

In math, an element of a Vector Space (a set of finite points on which certain mathematical operations can be performed)*.

*feel free to clean this up.
Quote:Original post by Daerax
your post was outside the scope of graveyard filla's question


Quote:Topic subject by graveyard filla
what a (math) vector is exactly?


I did my best to answer the "math" part of his question. And even then, I marked my post as "ramblings" once I realized it might not be that useful to someone just wanting to use the classic 2D vectors.

Quote:
-------A vector is:---
In math, an element of a Vector Space


As stated above, a Vector Space is defined by (commutative, associative) addition of vectors and (associative) multiplication by scalars in the base body.

EDIT: aside from this whole discussion, I'd like to know what the direction of the 0 vector is considered to be, in physics.
Quote:Original post by ToohrVyk
Quote:Original post by Daerax
your post was outside the scope of graveyard filla's question


Quote:Topic subject by graveyard filla
what a (math) vector is exactly?


I did my best to answer the "math" part of his question. And even then, I marked my post as "ramblings" once I realized it might not be that useful to someone just wanting to use the classic 2D vectors.



...

I guess... he sort of asked for that didn't he?... Hmm, I guess the saying be careful what you wish for would do nicely here.
wow, well, thanks everyone for your help. firstly, i didnt really understand most of your guys replies towards the end. sorry but im mathmatically retarded.... i only know some basic algabra and statistics, seeing as my major is CIS, im in the middle of taking the last math class ill ever have to take, which is statistics. also, ive never taken a physics class in my life.

anyway, thanks again everyone. when i said what is a (math) vector, i didnt know that a vector was a physics thing and not a math thing (in game programming). i only put (math) there so people wouldnt think i was talking about the std::vector. sorry for the confusion.

thanks a lot for all your guys help!
FTA, my 2D futuristic action MMORPG

This topic is closed to new replies.

Advertisement