Computer Graphics 1996

Answers on 3D Transformations

These are for the exercise classes. Questions that have a * besides them are more difficult and should be considered at some time, but not necessarily now.

1. Write down 4*4 matrices for each of the following:

  1. To translate by the vector (1,2,3)

    1 0 0 0
    0 1 0 0
    0 0 1 0
    1 2 3 0
    
  2. To scale with respect to the origin by the amount (2,4,6)

    2 0 0 0
    0 4 0 0
    0 0 6 0
    0 0 0 1
    
  3. To rotate around the z-axis by 45 degrees (note sin 45 = cos 45 = 1/sqrt(2))

    Let s = 1/sqrt(2)
    
    s	s	0	0
    -s	s 	0	0
    0	0	1 	0
    0	0	0	1
    
  4. To rotate around the x-axis by 45 degrees.

    1	0	0	0
    0	s	s	0
    0	-s	s	0
    0	0	0	1
    

2. Find the 4*4 transformation matrices in order to accomplish:

  1. Scaling an object with respect to the origin by 2 in x, y and z followed by a translation by (1,1,1).

    2 0 0 0 	1 0 0 0		2 0 0 0
    0 2 0 0	* 	0 1 0 0	=	0 2 0 0
    0 0 2 0 	0 0 1 0		0 0 2 0
    0 0 0 1		1 1 1 1		1 1 1 1
    
  2. Translation of an object by (1,1,1) followed by a scaling with respect to the origin by 2 in x, y and z.
    1 0 0 0		2 0 0 0		2 0 0 0
    0 1 0 0     * 	0 2 0 0	=	0 2 0 0
    0 0 1 0		0 0 2 0		0 0 2 0
    1 1 1 1		0 0 0 1   	2 2 2 1
    

Why are the two matrices different? The two matrices are different because if we scale first we scale with respect to the origin and then translate, compared to translating and then scaling. In the two cases the position with respect to the origin are different, so the effect will be different. Another way of thinking of it is that when we scale first, we change the unit of scale of the coordinate system, so that the meaning of the subsequent translation is different. Finally, matrix multiplication is non-commutative, ie, A*B != B*A.

3. Find a matrix that will do a scale by (a,b,c) with respect to the point (x,y,z).

Here we have to translate so that (x,y,z) is shifted to the origin, then scale and finally, translate back: hence, multiply together the 3 matrices:


1  0  0  0 	
0  1  0  0	
0  0  1  0 	
-x -y -z 1

*

a 0 0 0
0 b 0 0
0 0 c 0
0 0 0 1

*

1 0 0 0
0 1 0 0
0 0 1 0
x y z 1 

=

a	0	0	0
0	b	0	0
0 	0	c	0
x(1-a)  y(1-b)   z(1-c)	1
4. The transpose of a matrix with elements a[i,j] is the matrix with elements a[j,i]. (I.e., the rows become columns and the columns become rows). An orthogonal matrix is one which when multiplied by its transpose results in the identity matrix. Hence, the transpose is also the inverse of such a matrix. Amongst the various matrices (translation, scaling, rotation about X, Y and Z axes) - which are orthogonal?
translation is orthogonal
all rotations are orthogonal
scaling is not orthogonal.

5*. A matrix is specified in generic form as follows:


r 	r 	r 	0
r 	r 	r 	0
r 	r 	r 	0
a 	b 	c 	1

The r-values are not all equal, but denote a 3*3 sub-matrix that is orthogonal. Hence this entire matrix can be expressed as:
R 0
q 1
where R is the orthogonal 3*3 matrix, q is the vector (a,b,c), 0 is a 3*1 column vector of 0s. Find an expression for the inverse of this matrix.

6*. Suppose we have a plane (P) with equation ax + by + cz = d, and we wish to transform this plane by the 4*4 matrix A. Find a new plane equation, in terms of a,b,c and d, and the matrix A, that refers to the plane formed by transforming every point on P by matrix A.