CS430/536 Homework Assignment 3

Programming Problem:

1. In this assignment you will read polygons from the input file. The polygons will be clipped to and drawn inside the viewport. They will be drawn as filled polygons.

2. Modify your HW2 program to:

  1. Read a file containing an arbitrary number of polygons.
  2. Perform polygon filling (scan line algorithm, no flood filling).
  3. Define the resolution of your output image to be 501 x 501.
  4. All the command-line options implemented in HW1 should be supported, plus the following which implement viewport mapping. You should be able to process any subset of the options in any arbitrary order.
  5. [-j] The next argument is an integer lower bound in the x dimension of the viewport window (0)
  6. [-k] The next argument is an integer lower bound in the y dimension of the viewport window (0)
  7. [-o] The next argument is an integer upper bound in the x dimension of the viewport window (200)
  8. [-p] The next argument is an integer upper bound in the y dimension of the viewport window (200)
  9. The viewport coordinate system origin is in the lower left corner of your image. The X direction is to the right, and the Y direction is up.
  10. You may assume that the viewport parameters are greater than or equal to zero, and less then or equal to 500.
  11. Map the world window into the viewport.
  12. Clipping should occur along the outer boundaries of the viewport using the Sutherland-Hodgman algorithm from HW2.

  13. Steps in assignment
    1. Read in polygons
    2. Apply 2D transformations to them in world coordinates
    3. Clip polygons to world window
    4. Apply world-to-viewport transformstion
    5. (You can also apply the w-t-v transformation before clipping. You would then clip the transformed polygons to the viewport window)
    6. Scan fill transformed polygons into software frame buffer
    7. Write frame buffer to XPM file

  14. You can test your program with hw3.ps.
  15. The default option set for this assignment is equivalent to this command line.
        ./cs430_hw3 -f hw3.ps -a 0 -b 0 -c 250 -d 250 -j 0 -k 0 -o 200 -p 200 -s 1.0 -m 0 -n 0 -r 0 > out.xpm
  16. If the tester enters ./cs430_hw3 > out.xpm , the results should be the same as from the command line above, and produce the following image. Here is the XPM image file.
    PLEASE NOTE THAT THE BORDER IS NOT PART OF THE OUTPUT IMAGE. IT HAS BEEN PLACED AROUND THE IMAGE TO HIGHLIGHT THE POSITION OF THE VIEWPORT WITHIN THE WINDOW.

  17. Input/Output Example:
            i. Input: ./cs430_hw3 -f hw3.ps -a 0 -b 0 -c 500 -d 500 -j 0 -k 0 -o 500 -p 500 -s 1.0 -m 0 -n 0 -r 0 > hw3.xpm         ii. Output: Here is the XPM image file.

  18. Input/Output Example:
            i. Input: ./cs430_hw3 -f hw3.ps -a 110 -b 0 -c 410 -d 500 -j 0 -k 110 -o 500 -p 410 -s 1 -m 0 -n 0 -r 0 > hw3.xpm         ii. Output: Here is the XPM image file.

  19. Input/Output Example:
            i. Input: ./cs430_hw3 -f hw3.ps -a 10 -b 10 -c 500 -d 400 -j 10 -k 10 -o 500 -p 400 -s 1.2 -m 30 -n 20 -r 10 > hw3.xpm         ii. Output: Here is the XPM image file.

    3. Grading Scheme

    1. Previous features : 2 points
      • Clipping operations
      • Transformations
    2. Input file reading : 1 point
    3. Viewport mapping: 3 points
    4. Polygon filling : 4 points

    4. Submission Guidelines:

    1. Assignments must be submitted via WebCT.
    2. README file: explain the features of your program, language and OS used, compiler or interpreter used, name of file containing main(). Word documents will NOT be accepted.
    3. All source code. Your code must compile and run on tux (Linux). MacOS X is a negotiable possibility. The TA will use one of these as the test platform.
    4. Binary executable named cs430_hw3
    5. You may program in any language you like as long as you can deliver a usable executable on tux. Please contact the TA if you plan on using something other than C, C++ or Java.
    6. Your program will be run by the TA. Please do NOT submit any image files, Visual C++ project files, or anything not requested in this section. Your program must run on tux without the installation of "special" libraries.
    7. Makefile (optional but appreciated): have the default rule compile your program.
    8. Points will be deducted if submission guidelines are not followed.
    9. Further details about WebCT
      1. You can reach WebCT through DrexelOne.
      2. Choose Computer Graphics among your list of courses. There is an "assignments" link in the left frame which will give you the list of assignments in the right frame.
      3. Click on the assignment you wish to submit.
      4. Find your file and click Upload button.
      5. Hit Submit button. DO NOT FORGET TO HIT THE SUBMIT BUTTON AFTER YOU UPLOAD ALL YOUR FILES.

    NOTE: Your source code for all programming assignments will be run through a plagiarism detection system. This program uses compiler techniques which are invariant of syntax and style. If you are sharing code with other classmates, you will get caught. Please refer to the student handbook for actions that will be taken.


    Last modified on February 7, 2006.