CS 476 Computer Graphics, Homework #2

Due: Fri Sep 12 in class (extended from Weds Sep 10)
  1. Skim Hill Chapter 2 sections 2.1-2.3 (through page 70).
  2. Write a program to draw the big dipper (Figure 2.12; coordinates are given there), wait for a keypress or mouse click, erase the screen, and then draw a sierpinski gasket (adapt code from Figure 2.15), and wait for a second keypress or mouse click.
  3. Read GB Chapter 2 (pages 7-13, 19-32) and Chapter 3 (pages 59-69). Skim the rest of GB Chapter 2. Ask lots of questions by e-mail or in class.
  4. The following program draws 1000 semi-random lines. The unary operator ? i produces a random value between 1 and i.
    	procedure main()
    	   WOpen("size=500,500")
               every 1 to 1000 do {
    	      x := ?500
    	      y := ?500
    	      x2 := x + ?(500 - x)
    	      y2 := y + ?(x2 - x)
    	      DrawLine(x, y, x2, y2)
    	      }
    	end
    
    Translate the code to C / UIGUI using rand() (Kelley/Hill p. 55). Compare the times running your program using DrawLine (built-in), DrawLine0 (y=mx+b) from the lecture notes, and DrawLine1 (the Bresenham/midpoint algorithm).