   affine space
  This pretty much sums up my understanding of this concept: uh.... what?I've been looking at this wikipedia article http://en.wikipedia.org/wiki/Affine_spaceI'm fairly confused. The left side of my brain isn't particularly smart, but since there is no origin point in affine space, everything is.....relative?Okay, I wasn't really sure where I was going with that. I think I just demonstrated that I have not the slightest idea, but, I am willing to learn....hence posting this.   
  Affine space is the space that you are used to dealing with, more or less. The only difference is that an affine space doesn't necessarily have a metric, so there might be no notion of distance. Don't think too much about that.It is true that not having an origin sounds a little weird, but if you think of the world in terms of traditional Newton-style physics, where is the origin? You can use a reference system to asign coordinates to points. A reference system does have an origin, but it is a property of the reference system, not of the space itself. You could use a different point as origin, and everything should work the same.So what about affine space is it that you don't understand?   ;  So, that's mostly it? It just has no origin? I think I understand about the reference system.But, take a quick look at the wikipedia page, it has a little example with Smith and Jones, where Smith knows where the origin is and Jones thinks he knows where it is, so they have point a and b, etc, take a quick look.They're basically attempting to find a+b where a and b are points in space. Don't think the dimensionality matters, but it's affine.Here's the bit I'm unsure of:Quote:If the sum of the coefficients in a linear combination is 1, then Smith and Jones will agree on the answer! By "linear combination", are they just talking about a linear equation of some sort? Why will they have the same answer if the sum of the coefficients is 1?   ;  Well. The following is how I think of spaces. I hope it is mainly correct.We're working with an Euclidean space, since we're using the Euclidean norm to compute distances. Euclidean space is a special kind of affine space.An affine space is an extension to a vector space V. In vector space there are only _directions_, no points (and hence no origin of course). The extension to the affine space A means just to add a point construct defined by a mathematical set, so thatP + v in A for P in A and v in Vwhat verbosely means nothing other than a point plus a vector yields in a point (a fact that could be seen well in homogeneous co-ordinates). Then there are the 3 axioms that must be met (identity element, associativity, and uniqueness) for A being an affine space.There is no particular point in A that makes it special w.r.t. all other points. For each point the math above holds.However, we are using concrete co-ordinate tuples to describe particular points and/or direction vectors. To do so we need to set-up a frame to measure the co-ordinates in. This includes to fix a point where the co-ordinates are all 0. That is what is called the origin. But it is just an arbitrariness and not part of the definition of the affine space.EDIT: There is a similar construct in vector space: To be able to express a vector by co-ordinates, a _basis_ is fixed in the space. This basis is what we use as the principal axes. The basis together with the origin define the co-ordinate frame.[Edited by - haegarr on January 18, 2006 9:09:08 AM];Quote:Original post by EndarBut, take a quick look at the wikipedia page, it has a little example with Smith and Jones, where Smith knows where the origin is and Jones thinks he knows where it is, so they have point a and b, etc, take a quick look.They're basically attempting to find a+b where a and b are points in space. Don't think the dimensionality matters, but it's affine.Well, the sum of two points is not a well-defined operation. I think this is fairly intuitive. What is the sum of my location and yours? I have no idea how to define such a thing.Quote:Here's the bit I'm unsure of:Quote:If the sum of the coefficients in a linear combination is 1, then Smith and Jones will agree on the answer! By "linear combination", are they just talking about a linear equation of some sort? Why will they have the same answer if the sum of the coefficients is 1?A "linear combination" of some elements is just a weighted sum of those elements. So all this thing is saying is that given two points P and Q and scalars (think real numbers) x and y, the expression x*P + y*Q is well defined (i.e., doesn't depend on what reference system you use to define them) if and only if x+y=1. Well, and the same is true for more than two points, but let's think of two for now. The operation of taking a linear combination whose coefficients add up to one is called "taking a baricenter", and it is a well-defined operation in affine space.So the idea is that the sum of two points doesn't make sense, but the middle point between two points does. It also makes sense to talk about a point that is in between A and B and it's 20% of the way from A to B. If you are using a reference system and have coordinates for A and B, you can compute this new point as .8*A + .2*B. It doesn't matter what reference system you use, you'll always get the same point. You can do this for a couple of examples to convince yourself that the result doesn't depend on the reference.;Quote:Original post by EndarBy "linear combination", are they just talking about a linear equation of some sort? Why will they have the same answer if the sum of the coefficients is 1?Let's say that we have n points ui and n scalars ai such that sum[ ai ] = 1.If Jones performs a linear combination using those values he gets:c = sum[ aiui ]Smith, on the other hand, gets:c' = p + sum[ ai(ui - p) ] = p + sum[ aiui ] - sum[ ai ]p = p + sum[ aiui ] - p = c   ;  After looking at the wiki page cited in the opening post by Endar, I see correspondencies in my understanding of affine spaces and the wiki's "Precise definition" as well as its "Informal descriptions".Quote:Original from wiki pageImagine that Smith knows that a certain point is the true origin, and Jones believes that another point—call it p—is the origin. Two vectors, a and b, are to be added. Jones draws an arrow from p to a and another arrow from p to b, and completes the parallelogram to find what Jones thinks is a + b, but Smith knows that it is actually p + (a − p) + (b − p).With my understanding, the following is done here: p is clearly a point, written as P in the style I use (uppercase bold letter for points, lowecase bold letters for direction vectors). From the text the vectors a (A in my style) and b (B in my style) have to be points, too.The thing Jones does with A and B is not possible in affine space, as far as I know: Adding two points is not defined. From the construction Jones does it could be seen that he is actually adding A and B as they were direction vectors. That is exactly what Smith expresses by his formula:P + ( A − P ) + ( B − P )whereA − P =: adenotes the one direction vector, andB − P =: bthe other.Within homogeneous space (an extension to affine space) one gets the point in the middle of A and B if adding them. Obviously, this isn't the same point as Jones has constructed.However, I have no idea how the example of Jones and Smith should clarify affine spaces.[Edited by - haegarr on January 18, 2006 10:39:52 AM];  I don't think the example of Jones and Smith clarifies anything. The point is probably that one should consider the operation "compute barycenter" to be an important operation in affine spaces. For instance, if you have n+1 points not all contained in one hyperplane, you can express any point in the space using homogeneous barycentric coordinates.In graphics programming, I usually define a class Vector3D and a class Point3D. Both of these classes have the same data (`double x,y,z;'), but the operations allowed on them are different. This allows the compiler to detect where you are doing something that doesn't make sense. In C++ I overload operators so I can add two Vector3Ds, getting a Vector3D, or add a Point3D and a Vector3D, getting a Point3D. You can multiply a Vector3D with a scalar (double), but you can't multiply a Point3D with a scalar.The downside of this is that the compiler will not allow the operationM = (A+B)*.5;At least not with the vanilla implementation. You can get arround it by providing a function to compute barycenters:M = Barycenter(.5,A,.5,B);Or you could consider that the result of multiplying a double and a Point3D is a ScaledPoint3D, which consists of three coordinates plus a "weight", define the sum of ScaledPoint3Ds in the natural way (add the coordinates and the weights) and allow conversion from ScaledPoint3D to Point3D only if the weight of the ScaledPoint3D is 1.0 (or very close to 1.0, so floating-point errors don't kill you).I think most developers just use a single class Vector3D and use it for everything, and if they write something that doesn't make sense, they are responsible for the consequences.   ;Quote:Original post by alvaroThe point is probably that one should consider the operation "compute barycenter" to be an important operation in affine spaces. For instance, if you have n+1 points not all contained in one hyperplane, you can express any point in the space using homogeneous barycentric coordinates.I understood the main point of the explanation is to clarify the homogenity of an affine space w.r.t. points. Meanwhile I think the statement is this: The result of adding two points in the barycentric sense is independent of any particular origin (like adding two directions is independent of any particular orientation). That is what is expressed formally in the wiki's "Consequences" section (and verbosely more or less by Jones and Smith), and it is what the wiki points out as the definition of an affine space.I personally have another look at it, as already posted in a reply above. Especially "dropping the origin from a vector space to yield in an affine space" is either not understood by me, or else I have other basics for that. IMHO a vector space is a space of directions only, having no origin at all. First the addition of a set (even the points) makes a vector space to an affine space ...@alvaro: Not totally in topic:Quote:Original post by alvaroIn graphics programming, I usually define a class Vector3D and a class Point3D.This approach is fine in general since it uses an algebra on the space that is checkable by the compiler (as you've stated). I have used such approach for approx 3 years now, before I've unified points and directions 2 months ago :(It worked fine e.g. for distinction whether or not to consider the translational part of an affine transformation. However, it also has drawbacks. I found myself writing duplicate routines or else conversions to get the correct type. E.g. a pure rotation (in this case by a quaternion, but holds also for rotation matrices) should conveniently be done with points as well as with directions, or else with directions only in which case you have to subtract the null point first and add it later to yield in a point again.How do you deal with such things? Maybe with using template expressions the compiler is able to optimize out subtraction/addition of null vectors.   ;Quote:Original post by haegarrI personally have another look at it, as already posted in a reply above. Especially "dropping the origin from a vector space to yield in an affine space" is either not understood by me, or else I have other basics for that. IMHO a vector space is a space of directions only, having no origin at all. First the addition of a set (even the points) makes a vector space to an affine space ...I don't like the description of affine space as a vector space without origin. I guess the point is that a vector space has a special point, the vector 0, which is sometimes called the origin (although I don't like that name), while an affine space is a similar space where no point is special.Quote:Original post by haegarr@alvaro: Not totally in topic:Quote:Original post by alvaroIn graphics programming, I usually define a class Vector3D and a class Point3D.This approach is fine in general since it uses an algebra on the space that is checkable by the compiler (as you've stated). I have used such approach for approx 3 years now, before I've unified points and directions 2 months ago :(It worked fine e.g. for distinction whether or not to consider the translational part of an affine transformation. However, it also has drawbacks. I found myself writing duplicate routines or else conversions to get the correct type. E.g. a pure rotation (in this case by a quaternion, but holds also for rotation matrices) should conveniently be done with points as well as with directions, or else with directions only in which case you have to subtract the null point first and add it later to yield in a point again.How do you deal with such things? Maybe with using template expressions the compiler is able to optimize out subtraction/addition of null vectors.I don't think I have all the answers and I do end up with some duplicated code. In the case of pure rotations, the theory would say that they only apply to vectors. I guess when you talk about applying a pure rotation to a point it's in the context of rotating an entire model, by conviniently describing the model in a reference frame that has the rotation center as origin and then applying the pure rotation to the coordinates, or something like that. One option is considering that the coordinates of the model are vectors, since you are describing each point P by P-C, where C is the center of rotation. You then apply your pure rotation to all those vectors and add C back to obtain world coordinates.I hope that made some sort of sense.   