The x-, y-, and z-axis unit vectors (vectors that have a length of one) have their own special symbols: i, j, and k, respectively. So the x-axis unit vector is i=(1,0,0), etc.
Vectors are marked as alphabetical symbols with a line over them, or the symbol being written with a bold font. I'm naturally using here the latter way.
An unit vector is a vector whose length is one. We can calculate an unit vector from a vector by dividing all the terms of the vector by the length of the vector.
Calculating a vector's length is needed for example with phong shading and vertex normal calculation.
Problem: Let a = (1,1,1). Derive the unit vector which is parallel to a.
Note! Vectors are perpendicular when the angle between them is 90 degrees (cos90 = 0 -> a dot b = 0)!
Dot product is needed for example in phong illuminating and many other light manipulation operations.
Problem: Calculate the angle between the vectors
a+b and a-b, where a = (3,1) and b
= (1,-7).
All we need to do is to calculate the dot product of a and b and to multiply b by it:
a's component parallel to b = (a dot b)*b.
Note! a and b need not to be perpendicular to each other even though you might think so by looking at the picture X)
Some other things to remember about cross product:
The cross product expression can be written in an easy-to-remember form
by using determinants. A two-row determinant is defined as a table of
four numbers, the value of which is calculated as follows:
= ( Ay*Bz-By*Az , Az*Bx-Bz*Ax , Ax*By-Bx*Ay )
There's no restrictions in the size of a determinant, and all of them can be solved respectively. For example, from a four-row determinant we generate four three-row determinants etc.
Cross product is needed for example when calculating normals and plane equations.
Problem: Find the area of the parallelogram determined by the vectors (1,-1,2) and (2,3,-1).
Solution: (We use the hard way to demonstrate determinants)
= (-5,5,5).
Problem: Find a constant a so that the vectors (1,-1,2), (1,3,-1), and (a,-4,1) are on the same plane.
A specially ordered table of real or complex numbers is caller a
matrix:
The numbers a(y,x) are matrix elements. They form p rows and n columns. The type of the matrix is p x n; if needed, it can also be written together with the matrix symbol: A(pxn). The first index j of a matrix element a(j,k) shows the row on which the element is located; the latter index k shows respectively the column (the indices go thus like in C's tables: compared to the representation of a point (x,y), in matrices and C language tables the indices are (y,x)).
We use capital latin letters as names or symbols for matrices.
Matrices of the type 1 x n are called horizontal- or row vectors. Exceptionally, they are marked with small latin letters:
a = [ a(1) a(2) .. a(n) ]The elements can be separated with commas for clarity.
If the amounts of rows and columns in a matrix are equal, we call the
matrix a square matrix (cf. 3x3 or 4x4 matrices in 3D operations).
Matrix elements whose indices are equal form the diagonal of a square
matrix; in other words this is the line from the upper left corner to the
lower right corner of a matrix. If all the other elements than the ones on
the diagonal are equal to zero, we call the matrix a diagonal matrix:
A matrix whose all elements are zero, is called a zero matrix. The type of a zero matrix is not restricted. The symbol is O (or o if the matrix is a vector).
A matrix is called orthogonal if its row or column vectors (that is, the vectors formed by the rows or columns of the matrix) are perpendicular to each other and they are unit vectors.
A matrix B defined like this
A*B = I <=> B = A^(-1),is called the inverse matrix of A.
Matrix multiplication can be clarified by regarding it as the dot products of the vectors formed by the rows of the first matrix and the columns of the second matrix: first the uppermost row of the first matrix and the first column of the second matrix, then the same uppermost row of the first matrix and the second column of the second matrix, etc. And the results into the new matrix as in the picture above.
Note! Only certain types of matrices can be multiplied by each other. That is, if the first matrix is of the size p x q, the second one should be of the size q x r, where p, q, and r are not restricted. When we multiply a p x q sized matrix by a q x r sized matrix, we get a p x r sized matrix as a result, as can easily be seen from the definition of matrix multiplication.
Matrix multiplication is needed in object transformations.
1.2.2.3.1 Multiplying by a vector
The case is easiest to understand by making the desired vector a horizontal vector:
Xi+Yj+Zk = [ X Y Z ].Now we multiply this vector (which actually is a matrix) by the desired matrix,
Vector*matrix can be thought of as projecting the vector as related to the new coordinate axes (the ones in the matrix).
C(nxp) = AT,where C(j,k) = A(k,j). In other words, the matrix is 'flipped' around.
Transposition is needed when rotating round an arbitrary vector. NOTE! The transpose of an orthogonal matrix is also its inverse! (this piece of information is used in optimizing 3D routines -- see chapter 2.7.)
Back to the index