CS430/536 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.
%%%BEGIN
100 100 moveto
200 100 lineto
200 200 lineto
100 200 lineto
100 100 lineto
stroke
300 300 moveto
400 300 lineto
400 400 lineto
300 400 lineto
300 300 lineto
stroke
%%%END
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:
- Accept the "Moveto", "Lineto" and "Stroke" Postscript
commands.
- All the command-line options implemented in HW1 should be supported.
- Read in a polygon from a file, apply 2D transformations to it, clip it
against the world window using the Sutherland-Hodgman algorithm.
- Display the polygon edges with the code implemented in HW1.
- You can test your program with several files:
hw2_a.ps,
hw2_b.ps,
hw2_c.ps,
hw2_d.ps.
- Input/Output Example: (Dark border is the window boundary)
i. Input:
./cs430_hw2 -f hw2_a.ps -s 1.5 > hw2_ex1.xpm
ii. Output:
- Input/Output Example: (Dark border is the window boundary)
i. Input:
./cs430_hw2 -f hw2_a.ps -m -250 -n -200 > hw2_ex2.xpm
ii. Output:
- Input/Output Example: (Dark border is the window boundary)
i. Input:
./cs430_hw2 -f hw2_b.ps -a 170 -b 100 -c 270 -d 400 > hw2_ex3.xpm
ii. Output:
- Input/Output Example: (Dark border is the window boundary)
i. Input:
./cs430_hw2 -f hw2_b.ps -s 2 > hw2_ex4.xpm
ii. Output:
- Input/Output Example: (Dark border is the window boundary)
i. Input:
./cs430_hw2 -f hw2_c.ps -a 200 -b 100 -c 375 -d 400 > hw2_ex5.xpm
ii. Output:
- Input/Output Example: (Dark border is the window boundary)
i. Input:
./cs430_hw2 -f hw2_c.ps -a 275 -b 100 -c 550 -d 502 > hw2_ex6.xpm
ii. Output:
3. Grading Scheme
- Assignment 1 features : 2 points
- Comand-line argument reading
- Image format
- Line drawing
- Transformations
- Postscript reading : 1 point
- Polygon clipping : 7 points
4. Submission Guidelines:
- Assignments must be submitted via WebCT.
- 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. Word documents will NOT be accepted.
- 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.
- You may program in any language you like as long it can produce
a usable executable on tux. Please contact
the TA if you plan on using something other than C, C++ or Java.
- 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.
- Makefile (optional but appreciated): have the default
rule compile your program.
- Points will be deducted if submission guidelines are not followed.
- Further details about WebCT
- You can reach WebCT through DrexelOne.
- 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.
- Click on the assignment you wish to submit.
- Find your file and click Upload button.
- 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 October 19, 2008.