Elements of Computer Graphics CS 174, Spring 2002: Assignment 1 Solutions

1           Change of Coordinates

a. PO = (3,1), PA = (1, 0.5), PB = (-0.5, -0.5).

b. MOB = (MBA)-1 MOA.

c. MOB = MBO-1.

d. To apply the transformations T1,T2,T3 (in that order) to a coordinate system construct the matrix M=T1xT2xT3. Then M transforms points from the new system to the original one.

To apply the transformations T1,T2,T3 (in that order) to a point within a given coordinate system construct the matrix M=T3xT2xT1.

To align system B with O we have to do a series of transformations to the B coordinate system. Each transformation happens with respect to the current B system which is why we accumulate them from left to right. For example, scaling B by 1/sqrt(2) produces a new coordinate system B’ whose unit vectors have the same magnitude as the ones of  O.  Rotating B’ by  –45 aligns the axis with those of O and produces system B’’. Now the distance between the origin of B’’ and the origin of O is (-3,-2) with respect to the B’’ system. Therefore a final translation by (-3,-2) produces system B’’’ that totally coincides with O. Putting the transformations in order gives:

 If you think it is easier to find MAO and MBO and then invert, (MOB = (MBO)-1 and MOA=(MAO)-1 ) then you can also do that. Remember: .

Similarly,

=

To compute MAB we can make use of the matrices we have just calculated.

MAO =

MOB =



 


2           Transformations

  1. AB = B – A = (2,3,0) – (1,1,0)  =  (1,2,0).
  2. The unit vector is AB/|AB|. Since |AB| =  the unit vector is =(0.447,0.894).
  3. The unit vector along the given axis is: j = (1,1,0)/|(1,1,0)| = . The projection of a vector a along the axis j is a’=(a*j )j where ‘*’ indicates a dot product. The projection we are looking for is: (AB*j)j =((1,2,0)* )j=( ) =(1.5,1.5,0) ;
  4. We observe that the matrix can be decomposed into the product of a translation matrix and a rotation-around-z matrix:

=T(a,b,c)R(z,q)

           

 

3           Hardware

a. Each pixel needs 24 =3x8 bits => 3 bytes  for color. The frame buffer needs to provide   1024x1024 pixels per frame, at rate of 60 frames per second. So in total we need:

1024x1024x3x60 bytes/second= 3x60 MBytes/second= 180MBytes/second.

Remember that 1Mbyte = 1024Kbytes=1024x1024bytes.

b. The color map can hold  2^8 = 256 colors at maximum. Therefore the minimum number of colors that cannot fit in the color map is 512-256 = 256.