CS430/585 - Homework Assignment 4

Programming Problem:

1. The new command you'll be required to implement is:
    1. x1 y1 x2 y2 x3 y3 curveto
The curveto command draws a cubic bezier curve using the current position of the pen, and the three integer points given as control points. Each curve will be defined by a "moveto", "curveto", "stroke" triplet.

%%%BEGIN
10 10 moveto
20 20 130 130 250 20 curveto
stroke

250 20 moveto
120 120 170 170 50 20 curveto
stroke

350 350 moveto
370 400 425 450 450 400 curveto
stroke
%%%END

2. Modify your HW3 program to:
  1. Accept the "Curveto" Postscript command
  2. All the command line options and Postscript commands implemented in HW3 should be supported. NOTE: You should be able to process any subset of the command-line arguments in any arbitrary order.
  3. Draw the Bezier curve as a sequence of (potentially clipped) line segments.
  4. Define the resolution of your output image to be 501 x 501.
  5. Each Bezier curve is parameterized from 0 to 1.
  6. [-L] This option specifies the increment of the parameter u to be used when generating points on the curve. The next argument is a real number between 0 and 1. (0.05)
  7. Be sure to evaluate the curve only in the range 0 &le u &le 1, and to include both endpoints.
  8. You can test your program with hw4.ps.
  9. The default option set for this assignment is equivalent to this command line.
        ./cs430_hw4 -f hw4.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 -L 0.05 > out.xpm
  10. If the tester enters ./cs430_hw4 > 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.

  11. Input/Output Example:
            i. Input: ./cs430_hw4 -f hw4.ps -a 0 -b 0 -c 500 -d 500 -j 0 -k 0 -o 500 -p 500 > hw4.old.xpm         ii. Output: Here is the XPM image file.

  12. Input/Output Example:
            i. Input: ./cs430_hw4 -f hw4.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 -L 0.05 > hw4.xpm         ii. Output: Here is the XPM image file.

  13. Input/Output Example:
            i. Input: ./cs430_hw4 -f hw4.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 -L 0.05 > hw4.xpm         ii. Output: Here is the XPM image file.

  14. Input/Output Example:
            i. Input: ./cs430_hw4 -L 0.25 > hw4.xpm         ii. Output: Here is the XPM image file.


    3. Grading Scheme

    1. On-time : 2 points
    2. Image format correct : 1 point
    3. Transformations correct : 1 point
    4. Clipping correct : 1 point
    5. Parsing correct : 1 point
    6. Bezier curve evaluation/drawing correct : 4 points

    4. Submission Guidelines:
        1. Assignments must be submitted via submit command located on the queen unix machine.
        2. README file: explaining at least the features of your program, language used, compiler or interpreter used, etc. Word documents will NOT be accepted.
        3. All source code. Your code must compile and run on the Solaris operating system (queen CS dept machine). The TA's will use this as the test platform.
        4. Binary executable named cs430_hw4
        5. Your program will be run by the TA's. Please do NOT submit any image files, Visual C++ project files, or anything not requested in this section.
        6. Makefile (optional but appreciated): have the default rule compile your program.

    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 11, 2004.