CS430/585 Homework Assignment 2

Programming Problem:

1. The new Postscript commands you will be required to implement are:
    1.    x y moveto
    2.    x y lineto
    3.    stroke

moveto command simply moves the pen to a particular location without drawing anything.
The lineto command draws a line from the current position of the pen, to the point indicated.
The stroke command can be ignored in your program, but actually draws the line sequence in Postcript interpreters (e.g. gv).

The following commands will draw two boxes.

100 100 moveto
200 100 lineto
200 200 lineto
100 200 lineto
100 100 lineto

300 300 moveto
400 300 lineto
400 400 lineto
300 400 lineto
300 300 lineto

You can assume that a "moveto"/"stroke" pair defines a single closed polygon with no holes and with vertices given in counter-clockwise order.

2. Modify your HW1 program to:

  1. Accept the "Moveto", "Lineto" and "Stroke" Postscript commands.
  2. All the command-line options implemented in HW1 should be supported.
  3. Read in two polygons (first one is A, the second is B) and perform a Boolean operation on them depending on one of the following flags
    1. -A     union (A ∪ B)
    2. -I       intersection (A ∩ B)
    3. If neither flag is given, draw both polygons.
  4. Your program does not need to handle situations that produce mutiple polygons or polygons with holes.
  5. Display the polygon edges with the code implemented in HW1.
  6. Additional Weiler-Atherton resources
  7. You can test your program with several files that contain two polygons: hw2_a.ps, hw2_b.ps, hw2_c.ps.
  8. This is what hw2_a.ps looks like.

  9. This is what hw2_b.ps looks like.

  10. This is what hw2_c.ps looks like.

    3. Grading Scheme

    1. Assignment 1 features : 3 points
      • Comand-line argument reading
      • Image format
      • Edge drawing
      • Viewing/clipping operations
      • Transformations
    2. Postcript reading : 1 point
    3. Union operator : 3 points
    4. Intersection operator : 3 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 either queen (Solaris) or tux (Linux). MacOS X is a negotiable possibility. The TA will use one of these as the test platform.
    4. Binary executable named cs585_hw2
    5. You may program in any language you like as long as you can deliver a usable executable on queen or 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 queen or tux without the installation of "special" libraries.
    7. If programming in Java
      • Test on queen with version 1.4.1. This is how your assignment will be evaluated.
      • No class or jar files. Submit your java files.
    8. Makefile (optional but appreciated): have the default rule compile your program.
    9. Points will be deducted if submission guidelines are not followed.
    10. Futher details about WebCT
      1. You can reach WebCT from http://webct.drexel.edu.
      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.

    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 January 18, 2005.