13

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?

Robin Rodricks
  • 110,798
  • 141
  • 398
  • 607
  • 1
    better fit to http://math.stackexchange.com/ – Svisstack Oct 12 '10 at 10:52
  • 1
    @Svisstack : Not really. This issue has strong ties with programming, and by experience I know the answer is not as trivial as it seems. – Stefano Borini Oct 12 '10 at 11:36
  • if you need a clear and formal explanation, I remember finding one in this great book I strongly suggest to buy if you have to deal a lot with 3D graphics : http://www.amazon.com/Geometric-Computer-Graphics-Morgan-Kaufmann/dp/1558605940/ref=sr_1_1?ie=UTF8&qid=1286883423&sr=8-1 – Stefano Borini Oct 12 '10 at 11:38

7 Answers7

14

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
  • 68,820
  • 20
  • 127
  • 125
  • 1
    "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. – Yakov Galka Oct 12 '10 at 11:00
  • @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 Oct 12 '10 at 11:05
  • In general i find that lot of everything one needs to know about 3d was explained will by Apodaca in [Lore for TDs](http://www.scribd.com/doc/886637/1/The-Lore-of-the-TDs) – joojaa Dec 19 '12 at 20:31
2

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
  • 776,304
  • 153
  • 1,341
  • 1,358
  • 1
    -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 Oct 12 '10 at 11:14
  • 3
    @gspr: The final state is the same as the initial state. – Ignacio Vazquez-Abrams Oct 12 '10 at 11:14
  • 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 Oct 12 '10 at 11:21
  • 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 Oct 12 '10 at 11:29
  • Just to be clear, this means that without points there are no vectors, right, but that the existence of a point doesn't necessarily imply a vector? A vector requires two points, one usually being the origin, is that a good way to think of it? – dudewad Oct 30 '17 at 16:47
  • @dudewad: I don't know that I'd say "one usually being the origin", but the rest seems accurate. – Ignacio Vazquez-Abrams Oct 30 '17 at 16:53
1

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

sjngm
  • 12,423
  • 14
  • 84
  • 114
Bob
  • 11
  • 1
1

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
  • 305,152
  • 44
  • 369
  • 561
  • 1
    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 Oct 12 '10 at 12:20
  • 1
    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 Oct 12 '10 at 12:25
  • 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 Oct 12 '10 at 12:33
  • 1
    @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 Oct 12 '10 at 12:54
  • 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 Oct 12 '10 at 12:54
  • @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 Oct 12 '10 at 12:55
  • 1
    @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 Oct 12 '10 at 12:58
  • @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 Oct 12 '10 at 12:59
  • 1
    @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 Oct 12 '10 at 13:06
  • @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 Oct 12 '10 at 13:13
  • 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 Oct 12 '10 at 13:25
  • 1
    @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 Oct 12 '10 at 13:26
  • @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 Oct 12 '10 at 13:34
  • @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 Oct 12 '10 at 13:41
  • 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 Oct 12 '10 at 13:41
-1

In the context of game mathematics there is no difference.

Points are elements of an affine space. Vectors are elements of a vector (aka linear) space. When you choose an origin in an affine space it automatically induces a linear structure on that affine space. The contrary is also true: if you have a vector space it already satisfies all the axioms of an affine space.

The fact is that when it comes to computation, the only way to represent an affine space numerically is to use tuples of numbers, which also form a vector space.

Each object in a game always has an origin, and it is crucial to know where it is. That origin is set relative to the origin of the world, which is set relative to the origin of the camera/viewport. The vertices of the object are represented as vectors -- offsets from the object origin. You use matrix multiplication to transform the objects -- that is too a purely vector space operation (you cannot multiply an affine point by a matrix without specifying the origin first). Etc, etc... As we see all those triplets of numbers that we might think of as 'points' are actually vectors in the local coordinate system.

So is there any reason to distinguish between the two outside the study of algebra? It is an unnecessary abstraction, and unnecessary abstractions are harmful (KISS). So my answer is no, just go with a single vector type.

Or any topological space outside the context of game development.

Yakov Galka
  • 70,775
  • 16
  • 139
  • 220
  • 2
    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 Oct 12 '10 at 10:58
  • @Ignocio: yes it is. Heard of scaling? – Yakov Galka Oct 12 '10 at 11:01
  • 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 Oct 12 '10 at 11:03
  • Both are different concept-wise. – Manoj R Oct 12 '10 at 11:04
  • A zero-size entity existing within an arbitrary coordinate system. – Ignacio Vazquez-Abrams Oct 12 '10 at 11:09
  • @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. – Yakov Galka Oct 12 '10 at 11:16
  • But the difference between them *isn't* necessarily zero. – Ignacio Vazquez-Abrams Oct 12 '10 at 11:17
  • @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 Oct 12 '10 at 11:18
  • 1
    @gspr, Of course a general topological space may not be a vector space. But the question was about 3d game mathematics. – Yakov Galka Oct 12 '10 at 11:21
  • @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 Oct 12 '10 at 11:22
  • @gspr: That would require "vector space" to have some actual meaning and not just be a mathematical abstraction. – Ignacio Vazquez-Abrams Oct 12 '10 at 11:22
  • @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 Oct 12 '10 at 11:23
  • 2
    @Ignacio: It has a completely precise and well-defined meaning. Wikipedia gives a nice introduction: http://en.wikipedia.org/wiki/Vector_space#Definition – gspr Oct 12 '10 at 11:24
  • @gspr: So then what does (5, 2, -3.4, 8, -2) mean in vector space? – Ignacio Vazquez-Abrams Oct 12 '10 at 11:28
  • 3
    @Ignacio: Give me a basis and I'll answer your question. – Yakov Galka Oct 12 '10 at 11:32
  • 1
    @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 Oct 12 '10 at 11:33
  • @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 Oct 12 '10 at 11:45
  • @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. – Yakov Galka Oct 12 '10 at 11:47
  • -1: you may treat vectors and points the same, and may express them the same, but they are not the same. – Kirk Broadhurst Oct 12 '10 at 11:54
  • @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 Oct 12 '10 at 11:54
  • 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 Oct 12 '10 at 11:56
  • 1
    @Kirk: Then why not? No explanation, Ah? – Yakov Galka Oct 12 '10 at 11:57
  • @Ignacio: "coordinate system with tuples that represent ..." is exactly the same as "basis with tuples that represent ..." which is a vector space. – Yakov Galka Oct 12 '10 at 12:00
  • @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 Oct 12 '10 at 12:31
  • @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 Oct 12 '10 at 21:28
  • 1
    @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). – Yakov Galka Oct 13 '10 at 07:17
  • 1
    @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 Oct 13 '10 at 08:24
  • @KirkBroadhurst Having different definitions doesn't mean the defined objects might not be identical. (I'm thinking of the general case, not necessarily this one.) – ThomasW Oct 01 '14 at 01:33
-1

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
  • 3,197
  • 1
  • 21
  • 36
  • -1: See my comment to Ignacio Vazquez-Abrams' answer about a vector being a "change of state". – gspr Oct 12 '10 at 11:14
-2

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
  • 9,074
  • 7
  • 44
  • 71
  • 1
    -1: You're describing the concept of a straight line in Euclidean space. It is *not* the same as a vector. – gspr Oct 12 '10 at 11:03