Page 2 of 2

Re: Points/Vectors/Rectangles

Posted: Mon Mar 01, 2010 10:08 am
by K-Bal
Just wanted to add that a 3d-vector can also be defined in cylinderic and spheric coordinates (I am not a native speaker, so forgive me if I am not using standard terms).

Re: Points/Vectors/Rectangles

Posted: Mon Mar 01, 2010 1:57 pm
by XianForce
Completely answered my question, Gyro. Thanks =D

Re: Points/Vectors/Rectangles

Posted: Mon Mar 01, 2010 8:00 pm
by Falco Girgis
qpHalcy0n wrote:Lord no. The differences between points and vectors are HUGE.

As I've said, they're represented the same way. However the operations performed between then *ARE NOT* the same. It's important to abstract them because of what they mean, especially in terms of graphics.

Again, Points have location. No direction.
Vectors have direction, but no absolute location. (This has different meaning given context).
A vector MUST contain a dx and a dy otherwise there *IS* no definition for magnitude. It's a case where on the outside it looks the same, but on the inside they do wildly different things and represent completely different ideas.

Point - Point = Vector
Vector - Vector = Vector
Vector - Point = Point

Point + Point = Vector
Vector + Vector = Vector
Vector + Point = Point

Vectors can be normalized, projected as a LINE, they have different homogenization characteristics....the list goes on and on and on.

I think what's happening here is that you've merely scratched the very first atoms of the surface of the mathematics behind computer graphics :] Since you don't understand the implications yet you're going to try to make a hasty decision in terms of a design choice. Rest assured, there is a difference and you WILL see it later. It becomes HUGE later. If you mix them up you're in for some big fat headaches.
I had a little chat with qpHalcy0n, and I have decided to return to this topic.

We both agreed that what I said was technically correct (the position vector being geometrically interpreted as a displacement from the origin), but I kind of undermined what he was saying. Points and vectors are still different things. Representing a point as a vector works fine, but when you start talking about performing operations on that vector, things can get messy.

qpHalcy0n's chart above holds true. If you are subtracting the vector representing his position (which is a point) from another vector, the result is a point. You kind of have to remember whether or not certain operations actually make sense, given points (represented as vectors) and vectors.

So qpHalcy0n actually suggests having a point class that IS separate from a vector class, so that you aren't tempted to take a dot product, cross product, or anything of the sort that doesn't make sense with "points." It really is a good practice for a beginner, once he made me think about it.

Bottom line: Both methods are probably going to work completely fine for what you're doing. It's just when you start getting into linear algebra-y scenarios (physics, collision resolution, etc.) where the way that you interpret a vector matters. When this happens, if you're representing both of them as vectors, be wary of which are actually points and which are vectors.

Thanks, qp, for making me step back and realize how important this distinction really is.

Re: Points/Vectors/Rectangles

Posted: Mon Mar 01, 2010 8:08 pm
by XianForce
Well I guess I'll keep it then haha =D