View Full Version : [Help: Maths] Point operations
EtienneK
23-07-2008, 03:50 PM
Anyone have a link to where I can get information on Point operations? Vectors are easy. They can be added, scaled, dotted, crossed, etc.
But you can't really add two points together. And subtracting 2 points yields a Vector. But I'm not too sure about all the operations using Points. Like: can they be scaled? Also doesn't make much sense...
Anyone have a good resource online for me? I used to have a great link, but lost it. This one is also good (http://geometryalgorithms.com/Archive/algorithm_0301/algorithm_0301.htm), but doesn't really explain the operations. It just gives an implementation of a point and vector class.
Thanks.
dislekcia
23-07-2008, 04:10 PM
A point is simply a vector that you've given a meaning as a point in space... That means that a point is a vector from the origin of your space to that location.
With that in mind, you can do all the vector maths you would usually do, all you have to keep in mind is the meaning of your resultant vectors.
Subtracting point A from Point B gives you the vector from A to B. That can be used to determine the distance between the two points, a heading, whatever.
You can find a point halfway between two points by simply adding the points and dividing the resultant vector by 2.
If you scale a point, you're essentially scaling it away (or towards) the origin. If you have a shape made up out of multiple points, you can make that shape larger or smaller by scaling all the points equally. Similarly, you can move a shape by adding the same vector to all the points. This is the basis of the matrix math that underlies all 3D calculations.
There are loads of things you can do with points, the important thing is keeping in mind what your outputs tell you about your space. What else are you confused about?
EtienneK
23-07-2008, 04:27 PM
Well, just, in theory, some operations are not allowed on points that are allowed on vectors and vice versa.
As an example: vectors can't be translated. But points can.
Also, when working with matrices and homogeneous coordinates, points will be matrices in the form of [x y z 1], while vectors will be matrices in the form of [x y z 0].
I understand most of the math behind the two. I would just like a nice reference of the operations that can be applied to them.
dislekcia
23-07-2008, 07:44 PM
A vector can be translated... But then it no longer represents a single vector and is instead the sum of two vectors.
Like I said, you need to be aware of the meaning you assign to those values at all times.
EtienneK
23-07-2008, 08:08 PM
Vectors can be added, but they can't be translated. Matrix multiplication will show you why:
(2D Translation Matrix) X (Vector)
| 1 0 tx | | x | | x |
| 0 1 ty | | y | = | y |
| 0 0 1 | . | 0 | | 0 |
So translating 2D vector (x, y) with (tx, ty) yields (x, y) again.
Ok, so I'm being anal. And adding 2 vectors together is the "same" as translating it. But I just like my code to reflect real world maths as much as possible :) I also like to split my point and vector classes.
Anyway, I got some nice info in one of my old linear algebra text books. But thanks for the help anyway.
dislekcia
23-07-2008, 09:19 PM
We tend to call vectors with a 0 W term normals, because they provide directions.
Also, why on earth are you writing your own vector classes? That's just silly... It won't help your gameplay.
EtienneK
23-07-2008, 10:10 PM
'cause I like fiddling with the technical side of game coding :P
Powered by vBulletin® Version 4.2.4 Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.