Jump to content
  • Advertisement
Sign in to follow this  
graveyard filla

what a (math) vector is exactly?

This topic is 5161 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi, im a little confused about what the term vector means for a 2d game. is a vector just a Point, IE an x and y? but, im a little confused... does a vector mean an absolute position, ie, a players coordinates, OR, does it mean a relative position, ie a players velocity? or, (which i think it is), does it mean both inter-changibly? so should i give my objects a Vector position and Vector velocity members then? thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
Vectors are basically nothing more than a collection of two or more individual components that represnet directed line segments in the 2- and 3-component case.

Share this post


Link to post
Share on other sites
A vector is a direction and a magnitude. Velocity, acceleration, force, etc. are all vectors by defenition. Position is not a vector. However, even though a vector is not a point, it can be represented by an (x,y) position so vectors and points are usually used interchangeably in programming.

Share this post


Link to post
Share on other sites
if i remember right a vector is velocity in a given direction
ex: 200mph north. though its been at least a year since i use the term.

Share this post


Link to post
Share on other sites
It is intended to represent a direction and a magnitude, so a relative position would qualify. However, because a Point can be represented as a vector that starts from the origin, I typically just typedef a Point as a vector (despite the fact that not all vector operations really make sence for a point). This clarifies the distinction between vectors and points in my code and enhances readability. An alternative would be to redefine Point with all the necessary operations, but this involves duplication of code, and on occasion it is useful to treat a point as a vector from the origin (say to find the angle from a point to the ground in reference to the origin).

Share this post


Link to post
Share on other sites
A vector is something that has a direction and a length.

Position vectors are a convetional thing, you choose 1 point as origin and the vectors from the origin to any point are position vectors. Velocity is a vector quantity.

Share this post


Link to post
Share on other sites
Just to add further to what has been said in computer graphics we work generally work with something called affine space which has three entities scalars, points, and vectors, if you take the difference of two points you obtain a vector which has magnitude & direction, little diagram:

Point A Point B
. .


So B - A = Vector AB :

Point A Point B
. ----------------------> .
vector AB

Share this post


Link to post
Share on other sites
thanks for all the replies... this might sound pathetic, but im incredibly horrible at math. could you explain what you mean by "direction and magnitude"? IE, lets say that i make a vector represent a characters velocity, and hes moving to the left. his velocity vector would be

-5,0

so the magnitude is -5 and the direction is left?

also,
"However, because a Point can be represented as a vector that starts from the origin"

what does this mean? lets say my players position is currently (563,2301), are you saying this could be a vector since its really 563,2301 magnitude from the origin? is this what you mean?

the last thing that confused me was snk's post ^^^^. what is a scaler ? and why would the difference between 2 points be usefull exactly? wouldnt you need to "normalize" that value to get something usefull? i put it in quotes because im not even sure thats the right term, like i said im incredibly horrible at math.

thanks for anymore help!

Share this post


Link to post
Share on other sites
Quote:
Original post by graveyard filla
thanks for all the replies... this might sound pathetic, but im incredibly horrible at math. could you explain what you mean by "direction and magnitude"? IE, lets say that i make a vector represent a characters velocity, and hes moving to the left. his velocity vector would be

-5,0

so the magnitude is -5 and the direction is left?

No, magnitude is always positive. If his velocity vector is -5,0, then its direction is to the left and its magnitude is 5.
Quote:

also,
"However, because a Point can be represented as a vector that starts from the origin"

what does this mean? lets say my players position is currently (563,2301), are you saying this could be a vector since its really 563,2301 magnitude from the origin? is this what you mean?

If you start at the origin and travel towards (564,2301), then you have moved in a certain direction, and travelled a certain distance. That distance and direction is the vector that (564,2301) represents relative to the origin.
Quote:

the last thing that confused me was snk's post ^^^^. what is a scaler ? and why would the difference between 2 points be usefull exactly? wouldnt you need to "normalize" that value to get something usefull? i put it in quotes because im not even sure thats the right term, like i said im incredibly horrible at math.

A scalar is a number that's not a vector. It's a magnitude without a direction. And the difference between two points is often very useful. If you were to normalize that value you would get a vector representing the direction you would need to go to get from one point to the other but with a magnitude of one. Sometimes you might want to know how far apart they are as well, in which case you want to leave the magnitude intact.

Share this post


Link to post
Share on other sites
The direction of a component-wise (x,y[,z]) vector can be represented by drawing an arrow from the origin to the the coordinates of the vector on a graph. In this diagram, the length of the arrow is equivalent to the magnitude of the vector. By drawing in perpendicular lines, it should be obvious that the length of the arrow can be found via pythagoras' theorem (this is basically the same as the derivation of the distance formula).

For a vector v:

magnitude = sqrt (v.x2+v.y2)

or, for 3D

magnitude = sqrt (v.x2+v.y2+v.z2)

or, in some implementations you may see it as

magnitude = sqrt (dot(v,v))

This last example is equivalent to the other two, but it requires less maintenance.

There are some good articles here on Vectors. You should check them out.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!