Vector

 

A Vector is a quantity which has both magnitude and direction. We can't visualise a vector until will define a set of basis vectors. A basis is the thing which we start out with first of all and for us games programmers it is the world axis which we use. Our vectors are then defined in as linear combination of our basis, thus (for 3d):

World basis XYZ

X = [1 0 0]

Y = [0 1 0]

Z = [0 0 1]

 

Vector V = aX, bY, cZ

In practice you ignore the X Y Z part and just store the a b c part because X Y Z is implicit, but it is important to remember that you are really just specifying a linear combination of basis vectors.

 

 

Unit Vector

 

A unit vector is simply a vector who's length (or magnitude) is 1. These are extemely important in geometry because they allow transformations which do not alter the scale of the things being transformed. Such a vector is said to be normalised - i.e. divided by its length:

 

Unit V = V / ||V||

or in code

V /= sqrt(V_x2 + V_y2 + V_z2)

 

Orthogonal

 

A set of vectors is orthogonal when each one is at 90o to the others. A basis which is like this and in which the vectors are unit length is said to be orthonormal. This is also extremely important because it means transformations do not skew or scale in unwanted directions and it means that rotation can work as expected.

You can ensure that a matrix is orthonormal using a series of vector normalisation and cross product operations:

Matrix formed of vectors STQ

S /= ||S||

Q=TxS

Q /= ||Q||

T = SxQ

 

The cross products ensure orthogonality and the normalisations ensure unit length; the two requirements for orthonormalaity.

 

 

Determinant (of a 3x3 matrix)

 

The determinant always used to mistify me until I learned that really it just represents the volume contained by the basis vectors of the matrix (STQ here):

 

det = (SxT) . Q

 

The determinant is found using the scalar tripple product - which gives the signed volume of the parellelipiped formed by the basis vectors. Obviously if this is 0 then the matrix does not form a basis and cannot be inverted (you will have seen matrix inversion code check this before it goes any further), since if the volume is 0 then one or more basis vectors must be coincident.