Angle | cos   |        sin

0           1                0

30      √3/2            1/2

45      √2/2             √2/2

60      1/2               √3/2

90      0                 1

 

Easy questions:

1)      We have a 640x480 Raster screen, what size frame buffer in bytes is required to store pixel the colors for an RGB system?

 

2)      Draw the resulting diagram when I make the following GL calls

 

glBegin(GL_LINES);                                            V1

glVertex3fv(vertex1);                                        *

glVertex3fv(vertex2);                            V2*            *V3

glVertex3fv(vertex3);                               V4*   * V5

glVertex3fv(vertex4);

       glEnd();

3)      Know polygon shading, both the odd-even rule and the non-zero winding rule

 

 Line algorithms and anti-aliasing

4)      Run Bresenham’s algorithm (see homework1  for example)

a.       Be able to run the algorithm for m<1 and m>1

5)      Run DDA algorithm to antialias a line (see homework 2 for example)

a.       Be able to run the algorithm for m<1 and m>1

b.      Be able to do weighted antialiasing and unweighted antialiasing

6)      Run the midpoint circle algorithm (see homework 1 for example)

 

Transformations and Viewing: Scroll down for answer to #6

7)      I have a clipping window from (0,0) to (80, 40)

a.       Transform my clipping window data to a display window from (0,0) to (120,60).  Make sure you use OpenGL normalized viewing coordinates.  I need to see each step clearly.

 

b.      What type of matrix is this?

 

8)      Be able to rotate around an arbitrary axis in space.

a.       I wish to rotate an object 60 degrees around the line

(5, 5, 5) to (7, 7, 7)

b.      What are the transformation matrices that will achieve this rotation.  You do not have to multiply out the matrices.  Leave in the form of M1·M2·M3···MFinal

9)      Be able to generate a quaternion matrix

I wish to rotate an object 60 degrees about the axis (0, 0, 0) to (2, 2, 2)

Show me the quaternion transformation matrix

½ of the points awarded for determining s, a, b, and c

½ of the points for the matrix.

10)  Be able to transform objects through different spaces (see homework 2 #2)

a.       Local to world

b.      Local to something else’s local coordinates

11)  (15 points) Use the Cohen-Sutherland Line clipping Algorithm to clip the lines in the following diagram.  Clip in the order of Left, Right, Bottom, Top.  Show all steps. Determine the FIRST intersection calculation for the P1->P2 line.  After the first calculation, you may set up the intersection without solving.  Simply indicate p2’, p2’’…p2’’’’’’’’  or    p1’, p1’’,…p1’’’’’’’’. 

 

12)  (15 points) Use the Liang-Barsky Line clipping algorithm to clip the line from P1 to P2. Show all work.

.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Answer to #7 First transform from the clipping window to the normalized viewing coordinates.

| Sx   0   Tx|

| 0    Sy  Ty|

| 0     0   1  |

 

Sx=Xvmax-Xvmin/Xwmax-Xwmin

Tx=(Xwmax*Xvmin) – (Xvmax*Xwmin)/Xwmax-Xwmin

 

The transformation matrix from the clipping window to the normalized viewing coordinates is

| 2/80   0      -80/80 |

| 0        2/40  -40/40|

| 0         0         1     |

 

Now I need to transform the normalized viewing coordinates to the display window.

I use the same equations as above

 

The transformation matrix from the normalized viewing coordinates to the display window is

| 120/2    0      120/2 |

| 0        60/2     60/2 |

| 0         0          1     |

 

Now I need to transform in the correct order

| 60     0      60  |   | 2/80   0      -1 |

| 0       30     30 |   | 0      2/40   -1 |

| 0        0       1  |   | 0        0       1 |

 

 

| 3/2  0   0 |

| 0    3/2 0 |

| 0     0   1|

 

This looks exactly like a scaling matrix, which is to be expected in this case.

 

 


 

 

Answer to #8.

We must first translate the vector to the origin.  This is a translation of (-5, -5, -5)

Tx=      |1         0          0          -5 |

            |0          1         0          -5 |

            |0          0         1          -5 |

|0          0         0          1 |

 

Then we rotate around x to force the line into the yz plane

First find the unit vector.  U=( √3/3, √3/3, √3/3)

Then project on the yz plane  d=√ ((√3/3)2+ (√3/3)2)= √6/3

√3/3/√6/3=√3/√6= √2/2

Rxx ) = | 1       0          0          0 |

                | 0    αz/d             y/d     0 |

                | 0    αy/d             αz/d      0 |

                | 0    0         0         1 |

 

Rxx ) =| 1        0          0          0 |

       | 0       √2/2     –√2/2   0 |

       | 0       √2/2     √2/2     0 |

       | 0       0          0          1 |

 

Now rotate around y to z axis:

Ryy ) = | d/1       0       x/1     0 |

                | 0       1                0          0 |

                | αx/1   0                d/1       0 |

                | 0        0         0       1 |

Ryy ) = | √6/3    0       -√3/3   0 |

                | 0       1                0          0 |

                | √3/3  0               √6/3    0 |

                | 0        0         0       1 |

 

Rz ) =   | cos(60)        -sin(60)  0         0 |

                | sin(60)        cos(60)   0        0 |

                | 0                0                      1         0 |

                | 0                 0            0       1 |

 

Rz ) =    | 1/2 -√3/2   0           0 |

                | √3/2           1/2       0           0 |

                | 0                0                    1           0 |

                | 0                 0         0         1 |

 

Finally the transformation is

T(5,5,5)  ·   Rx(-θx ) ·Ry· (-θy ) ·Rz ) · Ryy ) ·Rxx )  ·  T(-5, -5, -5)

 

Answer to #9

I wish to rotate an object 60 degrees about the axis (0, 0, 0) to (2, 2, 2)

Show me the quaternion transformation matrix

½ of the points awarded for determining s, a, b, and c

½ of the points for the matrix.

 

First I need a unit vector this is U=( √3/3, √3/3, √3/3)  With this I need to determine s, a, b, c

S=cos(θ/2) = cos(60/2)=cos(30)= √3/2

A= sin(θ/2)ux = sin(θ/2) √3/3 = ½*√3/3= √3/6

B= sin(θ/2)uy = √3/6

C= sin(θ/2)uz =√3/6

 

Now the matrix

The matrix is

 | 1-2b2-2c2                   2ab-2sc            2ac+2sb                0            |

 | 2ab+2sc                    1-2a2-2c2                 2bc-2sa                 0            |

 | 2ac -2sb                    2bc+2sa           1-2a2 -2b2                         0              |

 |        0                                           0                    0                      1                 |

 

For our case since a=b=c:    a2= b2= c2= ab=ac=bc=( √3/6)( √3/6 )=3/36= (1/12)

sa=sb=sc =(√3/2)( √3/6)=3/12=1/4  

 

| 1-2 (1/12)-2(1/12)                      2(1/12) –2(1/4)                2(1/12)+2(1/4)                  0                |

 | 2(1/12)+2(1/4)                          1-2(1/12)- 2(1/12)                     2(1/12)-2(1/4)                  0                |

 | 2(1/12) -2(1/4)                          2(1/12)+2(1/4)                 1-2(1/12) -2(1/12)                          0               

 |        0                                                 0                                   0                                 1                         |

 

| 1/3                 -1/3                  2/3                    0                |

 | 2/3                1/3                                    -1/3                  0                 |

 | -1/3               2/3                   1/3                                      0                

 |        0                         0                         0                   1                         |

 


 

  answer to 11 Use the Cohen-Sutherland Line clipping Algorithm to clip the lines in the following diagram.  Clip in the order of Left, Right, Bottom, Top.  Show all steps.

Determine the FIRST intersection calculation for the P1->P2 line.  After the first calculation, you may set up the intersection without solving.  Simply indicate p2’, p2’’…p2’’’’’’’’  or    p1’, p1’’,…p1’’’’’’’’. 

 

First assign region codes to each point.

P1=0100

P2=1001

P3=1010

P4=0110

 

Because P3 & P4 have a 1 in the same position, The line is completely outside.  CLIP

 

P1=0100

P2=1001

1. Check Left most bit (left edge)  Intersection with left edge.

X=X0 + t(Xend – X0)

  10 = 20 + t(5-25) = 20-20t

  -10=-20t 

    t=1/2

Y=Y0 + t(Yend – Y0)

 Y=4 + 1/2(64-4) = 34

P2’=(10, 34)

 

P1  =0100

P2’=1000

 

2. Check second bit (right edge) Both 0’s so do nothing

3. Check the bottom bit, Intersection with bottom edge. Determine P1’

10=Y0 + t(Yend – Y0)

solve for t, find X value

 

P1’=0000

P2’=1000

 

4. Check top, intersection with top

30=Y0 + t(Yend – Y0)

solve for t, find x value.

 

DONE

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 Answer to 12 (15 points) Use the Liang-Barsky Line clipping algorithm to clip the line from P1to P2.  Show all work.

                                                                                                 rk= qk/ pk

p1= -Δx   q1 = x0-xwmin                                p1= 20   q1 = 25-10=15           r1=3/4

p2= Δx   q2 = xwmax -x0                                 p2= -20    q2 = 30 –25=5         r2=-1/4

p3= -Δy   q3 = y0-ywmin                                p3= -60   q3 = 4-10=-6            r2=1/10

p4= Δy   q4 = ywmax -y0                                 p4= 60    q4 = 24 –4=20           r2=1/3

 

U1 = max (0, -1/4,1/10) = 1/10

U2=min(1, 3/4, 1/3)=1/3

X=X0 + t(Xend – X0)

Y=Y0 + t(Yend – Y0)

U1=1/10          X=25+1/10(-20)  =25-2 = 23

                        Y=4+1/10(60) = 10

                        New vertex value (23,10)  (Clip from bottom)

 

 

U2=1/3            X=25+1/3(-20) = 25-20/3 = 18-1/3vi

                        Y=4+1/4(60)=10

New vertex value (18-1/3,10)  clipped on top (and left)

 

.