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 world window using the Sutherland-Hodgman algorithm from HW2.
  13. Your new program should be named CG_hw3.

  14. 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 transformation
    5. (You can also apply the w-t-v transformation before clipping. You would then clip the transformed polygons to the viewport window)
    6. Round polygon vertices to integers
    7. Scan fill transformed polygons into software frame buffer
    8. Write frame buffer to XPM file

  15. You can test your program with hw3.ps.
  16. If you are having problems with dangling edges from the concave shape or a with the overlapping edge in the "0",
    this file has broken the "S" into three separate polygons and the "0" into two separate polygons.
  17. The default option set for this assignment is equivalent to this command line.
        ./CG_hw3 -f hw3_split.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
  18. If the tester enters ./CG_hw3 > hw3_a.xpm , the results should be the same as from the command line above, and produce the following image.
    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.

  19. Input/Output Example:
            i. Input: ./CG_hw3 -f hw3_split.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_b.xpm
            ii. Output:

  20. Input/Output Example:
            i. Input:         i. Input: ./CG_hw3 -f hw3_split.ps -a 50 -b 0 -c 325 -d 500 -j 0 -k 110 -o 480 -p 410 -s 1 -m 0 -n 0 -r 0 > hw3_c.xpm
            ii. Output:

  21. Input/Output Example:
            i. Input: ./CG_hw3 -f hw3_split.ps -a 10 -b 10 -c 550 -d 400 -j 10 -k 10 -o 500 -p 400 -s 1.2 -m 6 -n 25 -r 8 > hw3_d.xpm
            ii. Output:

  22. Input/Output Example:
            i. Input: ./CG_hw3 -b 62 -c 500 -d 479 -r 75 -j 139 -o 404 -p 461 -s .85 -m 300 > hw3_e.xpm
            ii. Output:

  23. Input/Output Example:
            i. Input: ./CG_hw3 -a 275 -b 81 -c 550 -d 502 -r -37 -j 123 -k 217 -o 373 -p 467 > hw3_f.xpm
            ii. Output:

  24. Input/Output Example:
            i. Input: ./CG_hw3 -d 270 -c 435 -b 170 -a -100 -r -23 > hw3_g.xpm
            ii. Output:

  25. Input/Output Example:
            i. Input: ./CG_hw3 -a -135 -b -53 -c 633 -d 842 -m -23 -j 101 -p 415 -s 3.6 > hw3_h.xpm
            ii. Output:

    3. Grading Scheme

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

    4. Submission Guidelines:

    1. Assignments must be submitted via Bb Learn.
    2. README file: explain the features of your program, language and OS used, compiler or interpreter used, name of file containing main(), and how to compile/link your program. Text files only. Word and PDF documents will NOT be accepted.
    3. All source code. Your code must compile and run on tux (Linux).
    4. You may program in any language you like as long it can produce a usable executable named CG_hw3 on tux.
    5. 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.
    6. Makefile: have the default rule compile your program. Jar file, if using java.
    7. If you are using a language that doesn't produce an executable file, e.g. python, then be sure to include a script called CG_hw3 that accepts arguments and prints XPM to standard out.
    8. Points will be deducted if submission guidelines are not followed.
    9. Further details about Bb Learn
      1. You can reach Bb Learn 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 November 6, 2015.