views:

117

answers:

7

Does a 3D vector differ from a 3D point tuple (x,y,z) in the context of 3D game mathematics?

If they are different, then how do I calculate a vector given a 3d point?

+3  A: 

The difference is that a vector is an algebraic object that may or may not be given as the set of coordinates in some space. (thanks to bungalobill for correcting my sloppiness).

A point is just a point given by coordinates. Generally, one can conflate the two. If you are given a set of coordinates, and told that they constitute a 'point' with no further information (choice of basis, etc), then you can just hand that set of numbers back and legitimately claim to have produced a vector.

The largest difference between the two is that it makes no sense to do things to one that you can do to the other. For example,

  1. You can add vectors: <1 2 3> + <3 2 1> = <4 4 4>
  2. You can multiply (or scale) a vector by a number (generally called a scalar) 2 * <1 1 1> = <2 2 2>

  3. You can ask how far apart two points are: d((1, 2, 3), (3, 2, 1) = sqrt((1 - 3)2 + (2 - 2)2 + (3 - 1)2) = sqrt(8) ~= 2.82

A good intuitive way to think about the association between a vector and a point is that a vector tells you how to get from the origin (that one point in space to which we assign the coordinates (0, 0, 0)) to its associated point.

If you translate your coordinate system, then you get a new vector for the same point. Although the coordinates that make up the point will undergo the same translation so it's a pretty easy conflation to make between the two.

Likewise if rotate the coordinate system or apply some other transformation (e.g. a shear), then the coordinates and vector associated to the point will also change.

It's also possible for a vector to be something else entirely, for example a bounded function on the interval [0, 1] is a vector because you can multiply it by a real number and add it to another function on the interval and it will satisfy certain requirements (namely the axioms of a vectorspace). In this case one thinks of having one coordinate for each real number, x, in [0, 1] where the value of that coordinate is just f(x). So that's the easiest example of an infinite dimensional vector space.

There are all sorts of vector spaces and the notion that a vector is a 'point and a direction' (or whatever it's supposed to be) is actually pretty vacuous.

aaronasterling
"may or may not consist of a set of coordinates" from Zorn's lemma it follows that a basis always exists so any vector can be represented as a set of coordinates. Also it's true for finite dimensional spaces independently of AC.
ybungalobill
@ybungalobill. correct. I was being a little bit sloppy in that I meant "may or may not be *given* as a set of coordinates". I'll update.
aaronasterling
A: 

A vector is a line, that is a sequence of points but that it can be represented by two points, the starting and the ending point.

If you take the origin as the starting point, then you can describe your vector giving only the ending point.

vulkanino
-1: You're describing the concept of a straight line in Euclidean space. It is *not* the same as a vector.
gspr
+1  A: 

A vector represents a change from one state to another. To create one, you need two states (in this case, points), and then you subtract the initial state from the final state in order to get the resultant vector.

Ignacio Vazquez-Abrams
-1: Let V be any vector space. It has at least one element, namely the neutral additive element, which we'll call 0. In what way can it be said that "you need two states to create 0"?
gspr
@gspr: The final state is the same as the initial state.
Ignacio Vazquez-Abrams
@Ignacio: Of course you can *interpret* a vector as a transition of states, but it's at the very least confusing to state that "you need two states to create a vector". I just created a vector for you without even using the word states. You being able to interpret my vector as a change of states does not make such an interpretation neccessary (or at all common in linear algebra, which I guess is more important here).
gspr
@Ignacio: Re-reading my comment now I feel I'm coming off sort of aggressive. That's not the intention, so I hope you don't read if that way :-)
gspr
@gspr: Not at all.
Ignacio Vazquez-Abrams
A: 

No, there is no difference. Points are vectors. If you like to think of a vector as direction + magnitude, then point is just a vector from the origin of coordinates.

ybungalobill
Points are not vectors. Multiplying a vector by a constant results in a vector with a different magnitude. Multiplying a point by a constant is meaningless.
Ignacio Vazquez-Abrams
@Ignocio: yes it is. Heard of scaling?
ybungalobill
You can't scale a single point. You *can* scale multiple points in relation to each other, but the difference from one point to the next is... a vector.
Ignacio Vazquez-Abrams
Both are different concept-wise.
Manoj R
@Ignacio: How *you* define a point?
ybungalobill
A zero-size entity existing within an arbitrary coordinate system.
Ignacio Vazquez-Abrams
@Ignacio: Your definition is far from being formal since two different points are still "zero sized". Coordinate system is nothing more than a basis of a vector space. So points *are* vectors in that space. Although I agree with @Manoj that you may treat them different conceptually.
ybungalobill
But the difference between them *isn't* necessarily zero.
Ignacio Vazquez-Abrams
@Ignacio: A *vector* is merely nice jargon for a *point* in a *vector space*. So while your comment "points are not vectors" is in general true, since there are sets that are not vector spaces, I think it is quite misleading. You should write "not all points are vectors, but all vectors are points" to be clear.
gspr
@gspr, Of course a general topological space may not be a vector space. But the question was about 3d game mathematics.
ybungalobill
@ybungalobill, the main reason that I disagree with your conflation of points and vectors is that one often wants to regard a vector as some sort of operator (e.g a differential operator in the case of a tangent vector) whereas a _point_ is the location of the manifold where that operator acts.
aaronasterling
@gspr: That would require "vector space" to have some actual meaning and not just be a mathematical abstraction.
Ignacio Vazquez-Abrams
@ybungalobill: Yes, I stand corrected. +1: In the context of R^3, your answer that "points are vectors" is completely correct. And perhaps more importantly: It avoids introducing the needless complexity introduced my many of the other answers given here.
gspr
@Ignacio: It has a completely precise and well-defined meaning. Wikipedia gives a nice introduction: http://en.wikipedia.org/wiki/Vector_space#Definition
gspr
@gspr: So then what does (5, 2, -3.4, 8, -2) mean in vector space?
Ignacio Vazquez-Abrams
@Ignacio: Give me a basis and I'll answer your question.
ybungalobill
@Ignacio: As it stands, (5,2, -3.4, 8, -2) is meaningless "in a vector space", since I don't know which, and I don't know the basis you're using. In this context, of course, the natural interpretation is the linear combination 5e_1 + 2e_2 - 3.4e_3 + 8e_4 - 2e_5 in R^5 with the standard basis e_1,...,e_5. It's a point in a vector space (in this case R^5), and handy jargon for such an animal is a *vector*.
gspr
@ybungalobill: It's extremely difficult to give a basis for vector space that isn't defined in terms of "change of state", since that is what I believe vectors are. I am certainly open to other ideas of what the basis may be. @gspr: I must be missing something. What I read is that "vector space" is something that contains vectors, but vectors are themselves mathematical abstractions for... something else, then vector space is something that contains mathematical abstractions.
Ignacio Vazquez-Abrams
@Ignacio: My vector is that your definition of a point has exactly the same weakness. You speak of a coordinate system... which is a basis after all.
ybungalobill
-1: you may treat vectors and points the same, and may express them the same, but they are not the same.
Kirk Broadhurst
@Ignacio: I wouldn't use "a vector space is something that contains vectors" as a definition, as it's sort of circular (depending on how you think about it). A standard way to think about it is this: A vector space is a *set* with additional structure: Commutative and associative addition (which has a neutral element and inverses) and distributive scalar multiplication. (These are subject to a few more conditions, but space here is tight, see Wiki). So your vector space is "a set with some algebraic structure". Its elements are called *points* or *vectors* (this is just jargon, not essential).
gspr
You construct a coordinate system so that you can create tuples that represent...... I'm trying not to sound biased here, but I'm unable to think of anything that would complete that sentence that isn't some form of "state", so I'll leave the sentence unfinished. I am welcome to suggestions.
Ignacio Vazquez-Abrams
@Kirk: Then why not? No explanation, Ah?
ybungalobill
@Ignacio: "coordinate system with tuples that represent ..." is exactly the same as "basis with tuples that represent ..." which is a vector space.
ybungalobill
@Ignacio: Keep in mind that while mathematical structures are often created to mimic something else, such as state or things from the physical world, it is never part of the *definition*. You can probably do great things for your intuition by thinking of vectors as "things that change state", you should not have that come across as what vectors *are*. Of course OP probably doesn't want the abstract definition of a vector space here. That's fine. But then we should do the Right Thing: Tell him flat out what vectors and points are in his case (R^3); they're different words for the same thing.
gspr
@ybungalobill Very simple - you can add two vectors, but you can't add two points. You can calculate distance between two points, but you can't calculate distance between two vectors. I might talk about a point that is '60 km north' of here, and someone else might tell a story that involves travelling '60 km north' from an undefined or irrelevant location. Both are not describing about the same thing - I'm talking about a point (a place), whereas the other is talking about a vector (a direction and a distance). We use the same phrase, but it is plainly not the same thing.
Kirk Broadhurst
@Kirk, your reasoning shows that you're not a mathematician. Adding two points `a+b` is placing the origin of coordinates at point a and translating point b with the origin. It makes perfect sense. And *of course* you can calculate a distance between two vectors, that's called a *metric* (http://en.wikipedia.org/wiki/Metric_%28mathematics%29#Metrics_on_vector_spaces).
ybungalobill
@ybungalobill Unfortunately I once was a mathematician but that degree is getting pretty dusty. I see your reasoning and I don't disagree that a point and a vector can be thought of as the same thing, but they can also be thought of as different things. They are isomorphic, but that does not mean they are identical. Don't they have different definitions, after all?
Kirk Broadhurst
A: 

Vector is the change in the states. A point is the static point. Two vectors can be parallel or perpendicular. You can have product of two vectors which is a third vector. You can multiply a vector by a constant. You can add two vectors.
All these operations are not allowed on point. So program wise if you think both as a C++ class, there will be many such methods in the vector class but probably only Get and Set for point.

Manoj R
-1: See my comment to Ignacio Vazquez-Abrams' answer about a vector being a "change of state".
gspr
A: 

Does a 3D vector differ from a 3D point tuple (x,y,z) in the context of 3D game mathematics?

Traditionaly vector means a direction and speed. A point could be considered a vector from the world orgin of one time step. (even though it may not be considered mathematically pure)

If they are different, then how do I calculate a vector given a 3d point?

target-tower is the common mnemonic.

Careful on your usage of this. The resulting vector is really normal*velocity. If you want to change it into something useful in a game application: you will need to normalize the vector first.

Example: Joe is at (10,0,0) and he wants to go to (10,10,0) Target-Tower: (10,10,0)-(10,0,0)=(0,10,0) Normalize the resulting vector: (0,1,0) Apply "physics": (0,1,0) * speed*elapsed_time < speed = 3 and we'll say that the computer froze for a whole 2 seconds between the last step and this one for ease of computation > =(0,6,0) Add the resulting vector to Joes current point in space to get his next point in space: ... =(10,6,0)

Normal = vector/(sqrt(x*x+y*y+z*z))

...I think I have everything here

Bob
A: 

Vectors are a more general idea that a point in 3D space.

Vectors can have 2, 3, or n dimensions. They represent many quantities in the physical world (e.g., velocity, force, acceleration) besides position.

A mathematician would say that a vector is a first order tensor that transforms according to this rule:

u(i) = A(i, j)v(j)

You need both point and vector because they are different. A point in 3D space denoting position is a vector, but every vector is not a point in 3D space.

Then there's the computer science notion of a vector as a container - it's an abstraction for an array of values or references. This is a different concept from a mathematician's idea of a vector, because every vector container need not obey the first order tensor transformation law (e.g. a Vector of OrderItems). That's yet another separate idea.

It's important to keep all these in mind when talking about vectors and points.

duffymo
It really, really must be said so as not to confuse the original poster: If the space in question is R^3 with standard structure, then *point* and *vector* are just nice names for the same thing!
gspr
And I think a mathematician would say: "A vector space is an abelian group with a scalar multiplication satisfying (etc., etc.)". Wikipedia's definition has the whole story (including "the etc, etc" above) at http://en.wikipedia.org/wiki/Vector_space#Definition - no need to muck around with tensors or concepts from the physical world. Of course, the latter is great for intuition :-)
gspr
No, I think first order tensor is enough without bringing group theory into it. And I think making the distinction between the mathematical and computer science data structure ideas is key, because a lot of people who write Java don't know the difference. It's easy to be misled into thinking that the java.util.Vector should mean the mathematical concept. ArrayList is a big improvement.
duffymo
@duffymo: Nah, you're just repackaging it. Sure, saying "first order tensor" (sort of) avoids algebra until I ask "what's a tensor?". Then you'll have to fire up the machinery of algebra anyway. Thus, in order to just convey the basics, the common definition (as presented for example by Wikipedia) is far more sensible.
gspr
If you want to get fancy about it then it's just an embedding of a field in the endomorphism ring of an abelian group. (no need for etc. etc. ) For the abelian group R^3, the ring is the matrices and the embedding is x -> 3*I.
aaronasterling
@AaronMcSmooth: You're not referring to my definition, are you? I was trying precisely to avoid being fancy by giving the simple(st), common(est) definition there is. (Just checking, not clear if you're talking to me or duffymo).
gspr
@gspr sort of both I suppose although I think that the notion of abelian group is sufficiently elementary that it should be taught in high school: it's not though and most people won't have any idea what it is. It's (at the level necessary to understand its significance to a vector space) orders of magnitude simpler than a tensor though. Also, please don't think that I have _any_ objections to getting fancy ;)
aaronasterling
@Aaron: You're right. I really shouldn't have said "abelian group" to keep it as simple as possible. It was there to shorten my otherwise long definition. If I could change my comment now I would. I think we agree, then: The OP should not be confused by bringing fancy things into the picture, even though they're awesome :-) Thus, a vector space is what http://en.wikipedia.org/wiki/Vector_space#Definition says it is, and a vector is the same as a point or an element in a vector space. *In particular*, in the vector space R^3, which is useful for 3D graphics, a vector is the same as a point.
gspr
@gspr. I don't think that any harm was done by bringing the notion of a tensor into it (restricted to R^n). I dont think that that the explanation did any good. I also disagree that points and vectors are the same in _any_ context. A vector is an algebraic concept and a point is a topological concept. It can be argued that it does not harm to _conflate_ the two in R^3 but I don't like the idea of telling anybody that they are the same. If they have to hurt their head to understand the difference, then that's probably good for them anyways.
aaronasterling
@Aaron: No, I don't think it was harmful either (I didn't downvote). I commented on this answer to point out the possible presence of over-fancyfication (yep, let's say that's a word). I too disagree that points and vectors are the same in *every* context (I mean, there are plenty of spaces in which you talk of "points", that don't have the structure of a vector space). But if we're talking about a vector space, such as R^3 in the original post, then surely every mathematician uses "point" and "vector" interchangeably for *elements* of this set-with-vector-space-structure?
gspr
Aaron, if a point in 3D space transforms according to that relationship I cited, then it is indeed a vector. Your "topological concept" might be correct, but the transformation argument is more useful. You'll use that transformation if you do things like transform to a rotated coordinate system.
duffymo
@gspr Possible but it's abusing the language. You can actually make that conflation in any vector space. For any group G (not necessarily abelian) you can define a new group Trans(G) whose elements are mappings of the form S_a: G -> G, x |-> ax with the obvious group operation. This is isomorphic to, but not identical with G. Here the elements of G are points and elements of Trans(G) are vectors in the sense that we normally think of them. So R^3 (as a group) is the collection of points and Trans(R^3) is the set of vectors. Or that's one way of looking at it.
aaronasterling
@gspr. Also, I'm being rather pedantic for the case of R^3 but I do think it's a point that should be made. @duffymo, I have to be honest, my eyes glaze over at the concept of anything being useful but to the extent that I follow your argument, I have to agree. An explanation that A was a matrix derived from the partial derivatives of the change of coordinates would have improved the answer though I think.
aaronasterling
@gspr. My previous long comment actually implies that the simple definition of vector space I gave in an earlier comment I made conflates points and vectors but it's not so because points have nothing to do with vectors. Once a mathematician has a norm on a vector space then one is inclined to think of vectors as being points but only for intuition. Other than that, there's really nothing that the two have in common.
aaronasterling
I don't agree - it's not an abuse of the language. I'd say that your use of "conflation" and "isomorphic" are far more confusing to most folks here. I'd bet that more people would understand the idea of transforming a point from one coordinate system to another far better than your citations of group theory.
duffymo