CS430/536 - Homework Assignment 6

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. Write a program, named CG_hw6, to:
1. Accept the "Curveto" Postscript command
2. All the command line options 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. Note that -r defines the rotation of the curves!
8. Be sure to evaluate the curve only in the range 0 ≤ u ≤ 1, and to include both endpoints.
9. You can test your program with ExtraCredit.ps.
10. The steps in your program could be
1. Transform the control points with scale, rotation, then translation
2. Evaluate the Bezier curve to produce a series of line segments
3. Clip the line segments to the world window defined by a, b, c & d
4. Transform the clipped lines to the viewport in the image
5. Draw the lines
11. The default option set for this assignment is equivalent to this command line.
./CG_hw6 -f ExtraCredit.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
12. If the tester enters ./CG_hw6 > 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.

13. Input/Output Example:
i. Input: ./CG_hw6 -f ExtraCredit.ps -a 0 -b 0 -c 500 -d 500 -j 0 -k 0 -o 500 -p 500 > hw6_b.xpm         ii. Output: Here is the XPM image file.

14. Input/Output Example:
i. Input: ./CG_hw6 -f ExtraCredit.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 > hw6_c.xpm         ii. Output: Here is the XPM image file.

15. Input/Output Example:
i. Input: ./CG_hw6 -f ExtraCredit.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 > hw6_d.xpm         ii. Output: Here is the XPM image file.

16. Input/Output Example:
i. Input: ./CG_hw6 -L 0.25 > hw6_e.xpm         ii. Output: Here is the XPM image file.

17. Input/Output Example:
i. Input: ./CG_hw6 -a 110 -b 50 -c 410 -d 500 -j 123 -k 50 -o 379 -p 477 -L 0.125 > hw6_f.xpm         ii. Output: Here is the XPM image file.

18. Input/Output Example:
i. Input: ./CG_hw6 -a 40 -c 275 -d 275 -j 175 -k 55 -o 350 -p 425 -L 0.177 > hw6_g.xpm         ii. Output: Here is the XPM image file.

1. HW3 options correct : 0.5 point
2. Parsing input file correct : 1 point
3. Incremental curve segments correct : 1 point
4. Bezier curve evaluation/drawing correct : 2.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 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_hw6 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.